author | edouard |
Tue, 27 Oct 2009 16:32:54 +0100 | |
changeset 431 | fcd344deae84 |
parent 401 | 8106a853a7c7 |
child 427 | 7ac746c07ff2 |
permissions | -rw-r--r-- |
145
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
1 |
import wx, wx.grid |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
2 |
import wx.stc as stc |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
3 |
import keyword |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
4 |
|
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
5 |
if wx.Platform == '__WXMSW__': |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
6 |
faces = { 'times': 'Times New Roman', |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
7 |
'mono' : 'Courier New', |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
8 |
'helv' : 'Arial', |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
9 |
'other': 'Comic Sans MS', |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
10 |
'size' : 10, |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
11 |
'size2': 8, |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
12 |
} |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
13 |
else: |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
14 |
faces = { 'times': 'Times', |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
15 |
'mono' : 'Courier', |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
16 |
'helv' : 'Helvetica', |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
17 |
'other': 'new century schoolbook', |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
18 |
'size' : 12, |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
19 |
'size2': 10, |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
20 |
} |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
21 |
|
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
22 |
|
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
23 |
def AppendMenu(parent, help, id, kind, text): |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
24 |
if wx.VERSION >= (2, 6, 0): |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
25 |
parent.Append(help=help, id=id, kind=kind, text=text) |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
26 |
else: |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
27 |
parent.Append(helpString=help, id=id, kind=kind, item=text) |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
28 |
|
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
29 |
|
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
30 |
[ID_CPPEDITOR, |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
31 |
] = [wx.NewId() for _init_ctrls in range(1)] |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
32 |
|
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
33 |
CPP_KEYWORDS = ["asm", "auto", "bool", "break", "case", "catch", "char", "class", |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
34 |
"const", "const_cast", "continue", "default", "delete", "do", "double", |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
35 |
"dynamic_cast", "else", "enum", "explicit", "export", "extern", "false", |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
36 |
"float", "for", "friend", "goto", "if", "inline", "int", "long", "mutable", |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
37 |
"namespace", "new", "operator", "private", "protected", "public", "register", |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
38 |
"reinterpret_cast", "return", "short", "signed", "sizeof", "static", |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
39 |
"static_cast", "struct", "switch", "template", "this", "throw", "true", "try", |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
40 |
"typedef", "typeid", "typename", "union", "unsigned", "using", "virtual", |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
41 |
"void", "volatile", "wchar_t", "while"] |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
42 |
|
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
43 |
def GetCursorPos(old, new): |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
44 |
old_length = len(old) |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
45 |
new_length = len(new) |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
46 |
common_length = min(old_length, new_length) |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
47 |
i = 0 |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
48 |
for i in xrange(common_length): |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
49 |
if old[i] != new[i]: |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
50 |
break |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
51 |
if old_length < new_length: |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
52 |
if common_length > 0 and old[i] != new[i]: |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
53 |
return i + new_length - old_length |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
54 |
else: |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
55 |
return i + new_length - old_length + 1 |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
56 |
elif old_length > new_length or i < min(old_length, new_length) - 1: |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
57 |
if common_length > 0 and old[i] != new[i]: |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
58 |
return i |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
59 |
else: |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
60 |
return i + 1 |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
61 |
else: |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
62 |
return None |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
63 |
|
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
64 |
class CppEditor(stc.StyledTextCtrl): |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
65 |
|
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
66 |
fold_symbols = 3 |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
67 |
|
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
68 |
def __init__(self, parent, name, window, controler): |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
69 |
stc.StyledTextCtrl.__init__(self, parent, ID_CPPEDITOR, wx.DefaultPosition, |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
70 |
wx.DefaultSize, 0) |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
71 |
|
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
72 |
self.SetMarginType(1, stc.STC_MARGIN_NUMBER) |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
73 |
self.SetMarginWidth(1, 25) |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
74 |
|
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
75 |
self.CmdKeyAssign(ord('B'), stc.STC_SCMOD_CTRL, stc.STC_CMD_ZOOMIN) |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
76 |
self.CmdKeyAssign(ord('N'), stc.STC_SCMOD_CTRL, stc.STC_CMD_ZOOMOUT) |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
77 |
|
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
78 |
self.SetLexer(stc.STC_LEX_CPP) |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
79 |
self.SetKeyWords(0, " ".join(CPP_KEYWORDS)) |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
80 |
|
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
81 |
self.SetProperty("fold", "1") |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
82 |
self.SetProperty("tab.timmy.whinge.level", "1") |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
83 |
self.SetMargins(0,0) |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
84 |
|
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
85 |
self.SetViewWhiteSpace(False) |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
86 |
#self.SetBufferedDraw(False) |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
87 |
#self.SetViewEOL(True) |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
88 |
#self.SetEOLMode(stc.STC_EOL_CRLF) |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
89 |
#self.SetUseAntiAliasing(True) |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
90 |
|
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
91 |
self.SetEdgeMode(stc.STC_EDGE_BACKGROUND) |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
92 |
self.SetEdgeColumn(78) |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
93 |
|
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
94 |
# Setup a margin to hold fold markers |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
95 |
#self.SetFoldFlags(16) ### WHAT IS THIS VALUE? WHAT ARE THE OTHER FLAGS? DOES IT MATTER? |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
96 |
self.SetMarginType(2, stc.STC_MARGIN_SYMBOL) |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
97 |
self.SetMarginMask(2, stc.STC_MASK_FOLDERS) |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
98 |
self.SetMarginSensitive(2, True) |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
99 |
self.SetMarginWidth(2, 12) |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
100 |
|
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
101 |
if self.fold_symbols == 0: |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
102 |
# Arrow pointing right for contracted folders, arrow pointing down for expanded |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
103 |
self.MarkerDefine(stc.STC_MARKNUM_FOLDEROPEN, stc.STC_MARK_ARROWDOWN, "black", "black") |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
104 |
self.MarkerDefine(stc.STC_MARKNUM_FOLDER, stc.STC_MARK_ARROW, "black", "black") |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
105 |
self.MarkerDefine(stc.STC_MARKNUM_FOLDERSUB, stc.STC_MARK_EMPTY, "black", "black") |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
106 |
self.MarkerDefine(stc.STC_MARKNUM_FOLDERTAIL, stc.STC_MARK_EMPTY, "black", "black") |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
107 |
self.MarkerDefine(stc.STC_MARKNUM_FOLDEREND, stc.STC_MARK_EMPTY, "white", "black") |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
108 |
self.MarkerDefine(stc.STC_MARKNUM_FOLDEROPENMID, stc.STC_MARK_EMPTY, "white", "black") |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
109 |
self.MarkerDefine(stc.STC_MARKNUM_FOLDERMIDTAIL, stc.STC_MARK_EMPTY, "white", "black") |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
110 |
|
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
111 |
elif self.fold_symbols == 1: |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
112 |
# Plus for contracted folders, minus for expanded |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
113 |
self.MarkerDefine(stc.STC_MARKNUM_FOLDEROPEN, stc.STC_MARK_MINUS, "white", "black") |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
114 |
self.MarkerDefine(stc.STC_MARKNUM_FOLDER, stc.STC_MARK_PLUS, "white", "black") |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
115 |
self.MarkerDefine(stc.STC_MARKNUM_FOLDERSUB, stc.STC_MARK_EMPTY, "white", "black") |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
116 |
self.MarkerDefine(stc.STC_MARKNUM_FOLDERTAIL, stc.STC_MARK_EMPTY, "white", "black") |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
117 |
self.MarkerDefine(stc.STC_MARKNUM_FOLDEREND, stc.STC_MARK_EMPTY, "white", "black") |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
118 |
self.MarkerDefine(stc.STC_MARKNUM_FOLDEROPENMID, stc.STC_MARK_EMPTY, "white", "black") |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
119 |
self.MarkerDefine(stc.STC_MARKNUM_FOLDERMIDTAIL, stc.STC_MARK_EMPTY, "white", "black") |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
120 |
|
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
121 |
elif self.fold_symbols == 2: |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
122 |
# Like a flattened tree control using circular headers and curved joins |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
123 |
self.MarkerDefine(stc.STC_MARKNUM_FOLDEROPEN, stc.STC_MARK_CIRCLEMINUS, "white", "#404040") |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
124 |
self.MarkerDefine(stc.STC_MARKNUM_FOLDER, stc.STC_MARK_CIRCLEPLUS, "white", "#404040") |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
125 |
self.MarkerDefine(stc.STC_MARKNUM_FOLDERSUB, stc.STC_MARK_VLINE, "white", "#404040") |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
126 |
self.MarkerDefine(stc.STC_MARKNUM_FOLDERTAIL, stc.STC_MARK_LCORNERCURVE, "white", "#404040") |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
127 |
self.MarkerDefine(stc.STC_MARKNUM_FOLDEREND, stc.STC_MARK_CIRCLEPLUSCONNECTED, "white", "#404040") |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
128 |
self.MarkerDefine(stc.STC_MARKNUM_FOLDEROPENMID, stc.STC_MARK_CIRCLEMINUSCONNECTED, "white", "#404040") |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
129 |
self.MarkerDefine(stc.STC_MARKNUM_FOLDERMIDTAIL, stc.STC_MARK_TCORNERCURVE, "white", "#404040") |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
130 |
|
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
131 |
elif self.fold_symbols == 3: |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
132 |
# Like a flattened tree control using square headers |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
133 |
self.MarkerDefine(stc.STC_MARKNUM_FOLDEROPEN, stc.STC_MARK_BOXMINUS, "white", "#808080") |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
134 |
self.MarkerDefine(stc.STC_MARKNUM_FOLDER, stc.STC_MARK_BOXPLUS, "white", "#808080") |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
135 |
self.MarkerDefine(stc.STC_MARKNUM_FOLDERSUB, stc.STC_MARK_VLINE, "white", "#808080") |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
136 |
self.MarkerDefine(stc.STC_MARKNUM_FOLDERTAIL, stc.STC_MARK_LCORNER, "white", "#808080") |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
137 |
self.MarkerDefine(stc.STC_MARKNUM_FOLDEREND, stc.STC_MARK_BOXPLUSCONNECTED, "white", "#808080") |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
138 |
self.MarkerDefine(stc.STC_MARKNUM_FOLDEROPENMID, stc.STC_MARK_BOXMINUSCONNECTED, "white", "#808080") |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
139 |
self.MarkerDefine(stc.STC_MARKNUM_FOLDERMIDTAIL, stc.STC_MARK_TCORNER, "white", "#808080") |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
140 |
|
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
141 |
|
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
142 |
self.Bind(stc.EVT_STC_UPDATEUI, self.OnUpdateUI) |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
143 |
self.Bind(stc.EVT_STC_MARGINCLICK, self.OnMarginClick) |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
144 |
self.Bind(wx.EVT_KEY_DOWN, self.OnKeyPressed) |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
145 |
|
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
146 |
# Make some styles, The lexer defines what each style is used for, we |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
147 |
# just have to define what each style looks like. This set is adapted from |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
148 |
# Scintilla sample property files. |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
149 |
|
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
150 |
# Global default styles for all languages |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
151 |
self.StyleSetSpec(stc.STC_STYLE_DEFAULT, "face:%(mono)s,size:%(size)d" % faces) |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
152 |
self.StyleClearAll() # Reset all to be like the default |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
153 |
|
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
154 |
# Global default styles for all languages |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
155 |
self.StyleSetSpec(stc.STC_STYLE_DEFAULT, "face:%(mono)s,size:%(size)d" % faces) |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
156 |
self.StyleSetSpec(stc.STC_STYLE_LINENUMBER, "back:#C0C0C0,face:%(helv)s,size:%(size2)d" % faces) |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
157 |
self.StyleSetSpec(stc.STC_STYLE_CONTROLCHAR, "face:%(other)s" % faces) |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
158 |
self.StyleSetSpec(stc.STC_STYLE_BRACELIGHT, "fore:#FFFFFF,back:#0000FF,bold") |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
159 |
self.StyleSetSpec(stc.STC_STYLE_BRACEBAD, "fore:#000000,back:#FF0000,bold") |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
160 |
|
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
161 |
self.StyleSetSpec(stc.STC_C_COMMENT, 'fore:#408060') |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
162 |
self.StyleSetSpec(stc.STC_C_COMMENTLINE, 'fore:#408060') |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
163 |
self.StyleSetSpec(stc.STC_C_COMMENTDOC, 'fore:#408060') |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
164 |
self.StyleSetSpec(stc.STC_C_NUMBER, 'fore:#0076AE') |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
165 |
self.StyleSetSpec(stc.STC_C_WORD, 'bold,fore:#800056') |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
166 |
self.StyleSetSpec(stc.STC_C_STRING, 'fore:#2a00ff') |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
167 |
self.StyleSetSpec(stc.STC_C_PREPROCESSOR, 'bold,fore:#800056') |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
168 |
self.StyleSetSpec(stc.STC_C_OPERATOR, 'bold') |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
169 |
self.StyleSetSpec(stc.STC_C_STRINGEOL, 'back:#FFD5FF') |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
170 |
|
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
171 |
# register some images for use in the AutoComplete box. |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
172 |
#self.RegisterImage(1, images.getSmilesBitmap()) |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
173 |
self.RegisterImage(1, |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
174 |
wx.ArtProvider.GetBitmap(wx.ART_DELETE, size=(16,16))) |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
175 |
self.RegisterImage(2, |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
176 |
wx.ArtProvider.GetBitmap(wx.ART_NEW, size=(16,16))) |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
177 |
self.RegisterImage(3, |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
178 |
wx.ArtProvider.GetBitmap(wx.ART_COPY, size=(16,16))) |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
179 |
|
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
180 |
# Indentation size |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
181 |
self.SetTabWidth(2) |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
182 |
self.SetUseTabs(0) |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
183 |
|
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
184 |
self.Controler = controler |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
185 |
self.ParentWindow = window |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
186 |
|
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
187 |
self.DisableEvents = True |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
188 |
self.Name = name |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
189 |
self.CurrentAction = None |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
190 |
|
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
191 |
self.SetModEventMask(wx.stc.STC_MOD_BEFOREINSERT|wx.stc.STC_MOD_BEFOREDELETE) |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
192 |
|
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
193 |
self.Bind(wx.stc.EVT_STC_DO_DROP, self.OnDoDrop, id=ID_CPPEDITOR) |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
194 |
self.Bind(wx.EVT_KILL_FOCUS, self.OnKillFocus) |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
195 |
self.Bind(wx.stc.EVT_STC_MODIFIED, self.OnModification, id=ID_CPPEDITOR) |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
196 |
|
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
197 |
def OnModification(self, event): |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
198 |
if not self.DisableEvents: |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
199 |
mod_type = event.GetModificationType() |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
200 |
if not (mod_type&wx.stc.STC_PERFORMED_UNDO or mod_type&wx.stc.STC_PERFORMED_REDO): |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
201 |
if mod_type&wx.stc.STC_MOD_BEFOREINSERT: |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
202 |
if self.CurrentAction == None: |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
203 |
self.StartBuffering() |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
204 |
elif self.CurrentAction[0] != "Add" or self.CurrentAction[1] != event.GetPosition() - 1: |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
205 |
self.Controler.EndBuffering() |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
206 |
self.StartBuffering() |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
207 |
self.CurrentAction = ("Add", event.GetPosition()) |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
208 |
elif mod_type&wx.stc.STC_MOD_BEFOREDELETE: |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
209 |
if self.CurrentAction == None: |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
210 |
self.StartBuffering() |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
211 |
elif self.CurrentAction[0] != "Delete" or self.CurrentAction[1] != event.GetPosition() + 1: |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
212 |
self.Controler.EndBuffering() |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
213 |
self.StartBuffering() |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
214 |
self.CurrentAction = ("Delete", event.GetPosition()) |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
215 |
event.Skip() |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
216 |
|
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
217 |
def OnDoDrop(self, event): |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
218 |
self.ResetBuffer() |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
219 |
wx.CallAfter(self.RefreshModel) |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
220 |
event.Skip() |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
221 |
|
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
222 |
def IsViewing(self, name): |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
223 |
return self.Name == name |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
224 |
|
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
225 |
# Buffer the last model state |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
226 |
def RefreshBuffer(self): |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
227 |
self.Controler.BufferCFile() |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
228 |
if self.ParentWindow: |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
229 |
self.ParentWindow.RefreshTitle() |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
230 |
self.ParentWindow.RefreshEditMenu() |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
231 |
|
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
232 |
def StartBuffering(self): |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
233 |
self.Controler.StartBuffering() |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
234 |
if self.ParentWindow: |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
235 |
self.ParentWindow.RefreshTitle() |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
236 |
self.ParentWindow.RefreshEditMenu() |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
237 |
|
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
238 |
def ResetBuffer(self): |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
239 |
if self.CurrentAction != None: |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
240 |
self.Controler.EndBuffering() |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
241 |
self.CurrentAction = None |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
242 |
|
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
243 |
def RefreshView(self): |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
244 |
self.ResetBuffer() |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
245 |
self.DisableEvents = True |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
246 |
old_cursor_pos = self.GetCurrentPos() |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
247 |
old_text = self.GetText() |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
248 |
new_text = self.Controler.GetPartText(self.Name) |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
249 |
self.SetText(new_text) |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
250 |
new_cursor_pos = GetCursorPos(old_text, new_text) |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
251 |
if new_cursor_pos != None: |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
252 |
self.GotoPos(new_cursor_pos) |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
253 |
else: |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
254 |
self.GotoPos(old_cursor_pos) |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
255 |
self.ScrollToColumn(0) |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
256 |
self.EmptyUndoBuffer() |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
257 |
self.DisableEvents = False |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
258 |
|
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
259 |
self.Colourise(0, -1) |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
260 |
|
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
261 |
def RefreshModel(self): |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
262 |
self.Controler.SetPartText(self.Name, self.GetText()) |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
263 |
|
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
264 |
def OnKeyPressed(self, event): |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
265 |
if self.CallTipActive(): |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
266 |
self.CallTipCancel() |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
267 |
key = event.GetKeyCode() |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
268 |
|
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
269 |
if key == 32 and event.ControlDown(): |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
270 |
pos = self.GetCurrentPos() |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
271 |
|
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
272 |
# Tips |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
273 |
if event.ShiftDown(): |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
274 |
pass |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
275 |
## self.CallTipSetBackground("yellow") |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
276 |
## self.CallTipShow(pos, 'lots of of text: blah, blah, blah\n\n' |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
277 |
## 'show some suff, maybe parameters..\n\n' |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
278 |
## 'fubar(param1, param2)') |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
279 |
# Code completion |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
280 |
else: |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
281 |
self.AutoCompSetIgnoreCase(False) # so this needs to match |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
282 |
|
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
283 |
# Images are specified with a appended "?type" |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
284 |
self.AutoCompShow(0, " ".join([word + "?1" for word in CPP_KEYWORDS])) |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
285 |
else: |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
286 |
wx.CallAfter(self.RefreshModel) |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
287 |
event.Skip() |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
288 |
|
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
289 |
def OnKillFocus(self, event): |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
290 |
self.AutoCompCancel() |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
291 |
event.Skip() |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
292 |
|
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
293 |
def OnUpdateUI(self, evt): |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
294 |
# check for matching braces |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
295 |
braceAtCaret = -1 |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
296 |
braceOpposite = -1 |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
297 |
charBefore = None |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
298 |
caretPos = self.GetCurrentPos() |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
299 |
|
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
300 |
if caretPos > 0: |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
301 |
charBefore = self.GetCharAt(caretPos - 1) |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
302 |
styleBefore = self.GetStyleAt(caretPos - 1) |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
303 |
|
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
304 |
# check before |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
305 |
if charBefore and chr(charBefore) in "[]{}()" and styleBefore == stc.STC_P_OPERATOR: |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
306 |
braceAtCaret = caretPos - 1 |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
307 |
|
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
308 |
# check after |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
309 |
if braceAtCaret < 0: |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
310 |
charAfter = self.GetCharAt(caretPos) |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
311 |
styleAfter = self.GetStyleAt(caretPos) |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
312 |
|
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
313 |
if charAfter and chr(charAfter) in "[]{}()" and styleAfter == stc.STC_P_OPERATOR: |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
314 |
braceAtCaret = caretPos |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
315 |
|
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
316 |
if braceAtCaret >= 0: |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
317 |
braceOpposite = self.BraceMatch(braceAtCaret) |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
318 |
|
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
319 |
if braceAtCaret != -1 and braceOpposite == -1: |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
320 |
self.BraceBadLight(braceAtCaret) |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
321 |
else: |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
322 |
self.BraceHighlight(braceAtCaret, braceOpposite) |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
323 |
#pt = self.PointFromPosition(braceOpposite) |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
324 |
#self.Refresh(True, wxRect(pt.x, pt.y, 5,5)) |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
325 |
#print pt |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
326 |
#self.Refresh(False) |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
327 |
|
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
328 |
|
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
329 |
def OnMarginClick(self, evt): |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
330 |
# fold and unfold as needed |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
331 |
if evt.GetMargin() == 2: |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
332 |
if evt.GetShift() and evt.GetControl(): |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
333 |
self.FoldAll() |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
334 |
else: |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
335 |
lineClicked = self.LineFromPosition(evt.GetPosition()) |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
336 |
|
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
337 |
if self.GetFoldLevel(lineClicked) & stc.STC_FOLDLEVELHEADERFLAG: |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
338 |
if evt.GetShift(): |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
339 |
self.SetFoldExpanded(lineClicked, True) |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
340 |
self.Expand(lineClicked, True, True, 1) |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
341 |
elif evt.GetControl(): |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
342 |
if self.GetFoldExpanded(lineClicked): |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
343 |
self.SetFoldExpanded(lineClicked, False) |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
344 |
self.Expand(lineClicked, False, True, 0) |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
345 |
else: |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
346 |
self.SetFoldExpanded(lineClicked, True) |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
347 |
self.Expand(lineClicked, True, True, 100) |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
348 |
else: |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
349 |
self.ToggleFold(lineClicked) |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
350 |
|
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
351 |
|
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
352 |
def FoldAll(self): |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
353 |
lineCount = self.GetLineCount() |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
354 |
expanding = True |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
355 |
|
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
356 |
# find out if we are folding or unfolding |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
357 |
for lineNum in range(lineCount): |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
358 |
if self.GetFoldLevel(lineNum) & stc.STC_FOLDLEVELHEADERFLAG: |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
359 |
expanding = not self.GetFoldExpanded(lineNum) |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
360 |
break |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
361 |
|
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
362 |
lineNum = 0 |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
363 |
|
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
364 |
while lineNum < lineCount: |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
365 |
level = self.GetFoldLevel(lineNum) |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
366 |
if level & stc.STC_FOLDLEVELHEADERFLAG and \ |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
367 |
(level & stc.STC_FOLDLEVELNUMBERMASK) == stc.STC_FOLDLEVELBASE: |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
368 |
|
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
369 |
if expanding: |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
370 |
self.SetFoldExpanded(lineNum, True) |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
371 |
lineNum = self.Expand(lineNum, True) |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
372 |
lineNum = lineNum - 1 |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
373 |
else: |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
374 |
lastChild = self.GetLastChild(lineNum, -1) |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
375 |
self.SetFoldExpanded(lineNum, False) |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
376 |
|
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
377 |
if lastChild > lineNum: |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
378 |
self.HideLines(lineNum+1, lastChild) |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
379 |
|
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
380 |
lineNum = lineNum + 1 |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
381 |
|
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
382 |
|
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
383 |
|
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
384 |
def Expand(self, line, doExpand, force=False, visLevels=0, level=-1): |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
385 |
lastChild = self.GetLastChild(line, level) |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
386 |
line = line + 1 |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
387 |
|
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
388 |
while line <= lastChild: |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
389 |
if force: |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
390 |
if visLevels > 0: |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
391 |
self.ShowLines(line, line) |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
392 |
else: |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
393 |
self.HideLines(line, line) |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
394 |
else: |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
395 |
if doExpand: |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
396 |
self.ShowLines(line, line) |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
397 |
|
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
398 |
if level == -1: |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
399 |
level = self.GetFoldLevel(line) |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
400 |
|
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
401 |
if level & stc.STC_FOLDLEVELHEADERFLAG: |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
402 |
if force: |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
403 |
if visLevels > 1: |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
404 |
self.SetFoldExpanded(line, True) |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
405 |
else: |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
406 |
self.SetFoldExpanded(line, False) |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
407 |
|
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
408 |
line = self.Expand(line, doExpand, force, visLevels-1) |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
409 |
|
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
410 |
else: |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
411 |
if doExpand and self.GetFoldExpanded(line): |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
412 |
line = self.Expand(line, True, force, visLevels-1) |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
413 |
else: |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
414 |
line = self.Expand(line, False, force, visLevels-1) |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
415 |
else: |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
416 |
line = line + 1 |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
417 |
|
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
418 |
return line |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
419 |
|
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
420 |
|
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
421 |
#------------------------------------------------------------------------------- |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
422 |
# Helper for VariablesGrid values |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
423 |
#------------------------------------------------------------------------------- |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
424 |
|
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
425 |
class VariablesTable(wx.grid.PyGridTableBase): |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
426 |
|
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
427 |
""" |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
428 |
A custom wxGrid Table using user supplied data |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
429 |
""" |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
430 |
def __init__(self, parent, data, colnames): |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
431 |
# The base class must be initialized *first* |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
432 |
wx.grid.PyGridTableBase.__init__(self) |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
433 |
self.data = data |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
434 |
self.colnames = colnames |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
435 |
self.Parent = parent |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
436 |
# XXX |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
437 |
# we need to store the row length and collength to |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
438 |
# see if the table has changed size |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
439 |
self._rows = self.GetNumberRows() |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
440 |
self._cols = self.GetNumberCols() |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
441 |
|
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
442 |
def GetNumberCols(self): |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
443 |
return len(self.colnames) |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
444 |
|
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
445 |
def GetNumberRows(self): |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
446 |
return len(self.data) |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
447 |
|
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
448 |
def GetColLabelValue(self, col): |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
449 |
if col < len(self.colnames): |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
450 |
return self.colnames[col] |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
451 |
|
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
452 |
def GetRowLabelValues(self, row): |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
453 |
return row |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
454 |
|
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
455 |
def GetValue(self, row, col): |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
456 |
if row < self.GetNumberRows(): |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
457 |
if col == 0: |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
458 |
return row + 1 |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
459 |
else: |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
460 |
return str(self.data[row].get(self.GetColLabelValue(col), "")) |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
461 |
|
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
462 |
def GetValueByName(self, row, colname): |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
463 |
if row < self.GetNumberRows(): |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
464 |
return self.data[row].get(colname, None) |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
465 |
return None |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
466 |
|
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
467 |
def SetValue(self, row, col, value): |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
468 |
if col < len(self.colnames): |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
469 |
self.data[row][self.GetColLabelValue(col)] = value |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
470 |
|
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
471 |
def SetValueByName(self, row, colname, value): |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
472 |
if row < self.GetNumberRows(): |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
473 |
self.data[row][colname] = value |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
474 |
|
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
475 |
def ResetView(self, grid): |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
476 |
""" |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
477 |
(wxGrid) -> Reset the grid view. Call this to |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
478 |
update the grid if rows and columns have been added or deleted |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
479 |
""" |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
480 |
grid.BeginBatch() |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
481 |
for current, new, delmsg, addmsg in [ |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
482 |
(self._rows, self.GetNumberRows(), wx.grid.GRIDTABLE_NOTIFY_ROWS_DELETED, wx.grid.GRIDTABLE_NOTIFY_ROWS_APPENDED), |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
483 |
(self._cols, self.GetNumberCols(), wx.grid.GRIDTABLE_NOTIFY_COLS_DELETED, wx.grid.GRIDTABLE_NOTIFY_COLS_APPENDED), |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
484 |
]: |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
485 |
if new < current: |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
486 |
msg = wx.grid.GridTableMessage(self,delmsg,new,current-new) |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
487 |
grid.ProcessTableMessage(msg) |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
488 |
elif new > current: |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
489 |
msg = wx.grid.GridTableMessage(self,addmsg,new-current) |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
490 |
grid.ProcessTableMessage(msg) |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
491 |
self.UpdateValues(grid) |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
492 |
grid.EndBatch() |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
493 |
|
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
494 |
self._rows = self.GetNumberRows() |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
495 |
self._cols = self.GetNumberCols() |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
496 |
# update the column rendering scheme |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
497 |
self._updateColAttrs(grid) |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
498 |
|
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
499 |
# update the scrollbars and the displayed part of the grid |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
500 |
grid.AdjustScrollbars() |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
501 |
grid.ForceRefresh() |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
502 |
|
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
503 |
def UpdateValues(self, grid): |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
504 |
"""Update all displayed values""" |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
505 |
# This sends an event to the grid table to update all of the values |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
506 |
msg = wx.grid.GridTableMessage(self, wx.grid.GRIDTABLE_REQUEST_VIEW_GET_VALUES) |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
507 |
grid.ProcessTableMessage(msg) |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
508 |
|
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
509 |
def _updateColAttrs(self, grid): |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
510 |
""" |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
511 |
wxGrid -> update the column attributes to add the |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
512 |
appropriate renderer given the column name. |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
513 |
|
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
514 |
Otherwise default to the default renderer. |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
515 |
""" |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
516 |
|
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
517 |
typelist = None |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
518 |
accesslist = None |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
519 |
for row in range(self.GetNumberRows()): |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
520 |
for col in range(self.GetNumberCols()): |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
521 |
editor = None |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
522 |
renderer = None |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
523 |
colname = self.GetColLabelValue(col) |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
524 |
grid.SetReadOnly(row, col, False) |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
525 |
|
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
526 |
if colname == "Name": |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
527 |
editor = wx.grid.GridCellTextEditor() |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
528 |
elif colname == "Class": |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
529 |
editor = wx.grid.GridCellChoiceEditor() |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
530 |
editor.SetParameters("input,output") |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
531 |
elif colname == "Type": |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
532 |
pass |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
533 |
else: |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
534 |
grid.SetReadOnly(row, col, True) |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
535 |
|
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
536 |
grid.SetCellEditor(row, col, editor) |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
537 |
grid.SetCellRenderer(row, col, renderer) |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
538 |
|
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
539 |
grid.SetCellBackgroundColour(row, col, wx.WHITE) |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
540 |
|
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
541 |
def SetData(self, data): |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
542 |
self.data = data |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
543 |
|
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
544 |
def GetData(self): |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
545 |
return self.data |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
546 |
|
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
547 |
def GetCurrentIndex(self): |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
548 |
return self.CurrentIndex |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
549 |
|
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
550 |
def SetCurrentIndex(self, index): |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
551 |
self.CurrentIndex = index |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
552 |
|
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
553 |
def AppendRow(self, row_content): |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
554 |
self.data.append(row_content) |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
555 |
|
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
556 |
def RemoveRow(self, row_index): |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
557 |
self.data.pop(row_index) |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
558 |
|
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
559 |
def MoveRow(self, row_index, move, grid): |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
560 |
new_index = max(0, min(row_index + move, len(self.data) - 1)) |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
561 |
if new_index != row_index: |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
562 |
self.data.insert(new_index, self.data.pop(row_index)) |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
563 |
grid.SetGridCursor(new_index, grid.GetGridCursorCol()) |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
564 |
|
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
565 |
def GetRow(self, row_index): |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
566 |
return self.data[row_index] |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
567 |
|
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
568 |
def Empty(self): |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
569 |
self.data = [] |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
570 |
self.editors = [] |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
571 |
|
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
572 |
|
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
573 |
[ID_VARIABLESEDITOR, ID_VARIABLESEDITORVARIABLESGRID, |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
574 |
ID_VARIABLESEDITORADDVARIABLEBUTTON, ID_VARIABLESEDITORDELETEVARIABLEBUTTON, |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
575 |
ID_VARIABLESEDITORUPVARIABLEBUTTON, ID_VARIABLESEDITORDOWNVARIABLEBUTTON |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
576 |
] = [wx.NewId() for _init_ctrls in range(6)] |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
577 |
|
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
578 |
class VariablesEditor(wx.Panel): |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
579 |
|
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
580 |
if wx.VERSION < (2, 6, 0): |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
581 |
def Bind(self, event, function, id = None): |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
582 |
if id is not None: |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
583 |
event(self, id, function) |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
584 |
else: |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
585 |
event(self, function) |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
586 |
|
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
587 |
def _init_coll_MainSizer_Growables(self, parent): |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
588 |
parent.AddGrowableCol(0) |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
589 |
parent.AddGrowableRow(0) |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
590 |
|
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
591 |
def _init_coll_MainSizer_Items(self, parent): |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
592 |
parent.AddWindow(self.VariablesGrid, 0, border=0, flag=wx.GROW) |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
593 |
parent.AddSizer(self.ButtonsSizer, 0, border=0, flag=wx.GROW) |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
594 |
|
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
595 |
def _init_coll_ButtonsSizer_Growables(self, parent): |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
596 |
parent.AddGrowableCol(0) |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
597 |
parent.AddGrowableRow(0) |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
598 |
|
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
599 |
def _init_coll_ButtonsSizer_Items(self, parent): |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
600 |
parent.AddWindow(self.AddVariableButton, 0, border=0, flag=wx.ALIGN_RIGHT) |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
601 |
parent.AddWindow(self.DeleteVariableButton, 0, border=0, flag=0) |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
602 |
parent.AddWindow(self.UpVariableButton, 0, border=0, flag=0) |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
603 |
parent.AddWindow(self.DownVariableButton, 0, border=0, flag=0) |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
604 |
|
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
605 |
def _init_sizers(self): |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
606 |
self.MainSizer = wx.FlexGridSizer(cols=1, hgap=0, rows=2, vgap=4) |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
607 |
self.ButtonsSizer = wx.FlexGridSizer(cols=5, hgap=5, rows=1, vgap=0) |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
608 |
|
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
609 |
self._init_coll_MainSizer_Growables(self.MainSizer) |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
610 |
self._init_coll_MainSizer_Items(self.MainSizer) |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
611 |
self._init_coll_ButtonsSizer_Growables(self.ButtonsSizer) |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
612 |
self._init_coll_ButtonsSizer_Items(self.ButtonsSizer) |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
613 |
|
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
614 |
self.SetSizer(self.MainSizer) |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
615 |
|
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
616 |
def _init_ctrls(self, prnt): |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
617 |
wx.Panel.__init__(self, id=ID_VARIABLESEDITOR, name='', parent=prnt, |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
618 |
size=wx.Size(0, 0), style=wx.SUNKEN_BORDER) |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
619 |
|
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
620 |
self.VariablesGrid = wx.grid.Grid(id=ID_VARIABLESEDITORVARIABLESGRID, |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
621 |
name='VariablesGrid', parent=self, pos=wx.Point(0, 0), |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
622 |
size=wx.Size(-1, -1), style=wx.VSCROLL) |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
623 |
self.VariablesGrid.SetFont(wx.Font(12, 77, wx.NORMAL, wx.NORMAL, False, |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
624 |
'Sans')) |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
625 |
self.VariablesGrid.SetLabelFont(wx.Font(10, 77, wx.NORMAL, wx.NORMAL, |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
626 |
False, 'Sans')) |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
627 |
if wx.VERSION >= (2, 5, 0): |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
628 |
self.VariablesGrid.Bind(wx.grid.EVT_GRID_CELL_CHANGE, self.OnVariablesGridCellChange) |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
629 |
self.VariablesGrid.Bind(wx.grid.EVT_GRID_CELL_LEFT_CLICK, self.OnVariablesGridCellLeftClick) |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
630 |
self.VariablesGrid.Bind(wx.grid.EVT_GRID_EDITOR_SHOWN, self.OnVariablesGridEditorShown) |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
631 |
else: |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
632 |
wx.grid.EVT_GRID_CELL_CHANGE(self.VariablesGrid, self.OnVariablesGridCellChange) |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
633 |
wx.grid.EVT_GRID_CELL_LEFT_CLICK(self.VariablesGrid, self.OnVariablesGridCellLeftClick) |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
634 |
wx.grid.EVT_GRID_EDITOR_SHOWN(self.VariablesGrid, self.OnVariablesGridEditorShown) |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
635 |
|
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
636 |
self.AddVariableButton = wx.Button(id=ID_VARIABLESEDITORADDVARIABLEBUTTON, label='Add Variable', |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
637 |
name='AddVariableButton', parent=self, pos=wx.Point(0, 0), |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
638 |
size=wx.Size(122, 32), style=0) |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
639 |
self.Bind(wx.EVT_BUTTON, self.OnAddVariableButton, id=ID_VARIABLESEDITORADDVARIABLEBUTTON) |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
640 |
|
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
641 |
self.DeleteVariableButton = wx.Button(id=ID_VARIABLESEDITORDELETEVARIABLEBUTTON, label='Delete Variable', |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
642 |
name='DeleteVariableButton', parent=self, pos=wx.Point(0, 0), |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
643 |
size=wx.Size(122, 32), style=0) |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
644 |
self.Bind(wx.EVT_BUTTON, self.OnDeleteVariableButton, id=ID_VARIABLESEDITORDELETEVARIABLEBUTTON) |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
645 |
|
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
646 |
self.UpVariableButton = wx.Button(id=ID_VARIABLESEDITORUPVARIABLEBUTTON, label='^', |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
647 |
name='UpVariableButton', parent=self, pos=wx.Point(0, 0), |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
648 |
size=wx.Size(32, 32), style=0) |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
649 |
self.Bind(wx.EVT_BUTTON, self.OnUpVariableButton, id=ID_VARIABLESEDITORUPVARIABLEBUTTON) |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
650 |
|
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
651 |
self.DownVariableButton = wx.Button(id=ID_VARIABLESEDITORDOWNVARIABLEBUTTON, label='v', |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
652 |
name='DownVariableButton', parent=self, pos=wx.Point(0, 0), |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
653 |
size=wx.Size(32, 32), style=0) |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
654 |
self.Bind(wx.EVT_BUTTON, self.OnDownVariableButton, id=ID_VARIABLESEDITORDOWNVARIABLEBUTTON) |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
655 |
|
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
656 |
self._init_sizers() |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
657 |
|
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
658 |
def __init__(self, parent, window, controler): |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
659 |
self._init_ctrls(parent) |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
660 |
|
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
661 |
self.ParentWindow = window |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
662 |
self.Controler = controler |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
663 |
|
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
664 |
self.VariablesDefaultValue = {"Name" : "", "Class" : "input", "Type" : ""} |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
665 |
self.Table = VariablesTable(self, [], ["#", "Name", "Class", "Type"]) |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
666 |
self.ColAlignements = [wx.ALIGN_RIGHT, wx.ALIGN_LEFT, wx.ALIGN_LEFT, wx.ALIGN_LEFT] |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
667 |
self.ColSizes = [40, 200, 150, 150] |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
668 |
self.VariablesGrid.SetTable(self.Table) |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
669 |
self.VariablesGrid.SetRowLabelSize(0) |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
670 |
for col in range(self.Table.GetNumberCols()): |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
671 |
attr = wx.grid.GridCellAttr() |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
672 |
attr.SetAlignment(self.ColAlignements[col], wx.ALIGN_CENTRE) |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
673 |
self.VariablesGrid.SetColAttr(col, attr) |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
674 |
self.VariablesGrid.SetColSize(col, self.ColSizes[col]) |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
675 |
self.Table.ResetView(self.VariablesGrid) |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
676 |
|
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
677 |
def IsViewing(self, name): |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
678 |
return name == "Variables" |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
679 |
|
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
680 |
def RefreshModel(self): |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
681 |
self.Controler.SetVariables(self.Table.GetData()) |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
682 |
self.RefreshBuffer() |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
683 |
|
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
684 |
def ResetBuffer(self): |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
685 |
pass |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
686 |
|
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
687 |
# Buffer the last model state |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
688 |
def RefreshBuffer(self): |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
689 |
self.Controler.BufferCFile() |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
690 |
self.ParentWindow.RefreshTitle() |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
691 |
self.ParentWindow.RefreshEditMenu() |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
692 |
|
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
693 |
def RefreshView(self): |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
694 |
self.Table.SetData(self.Controler.GetVariables()) |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
695 |
self.Table.ResetView(self.VariablesGrid) |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
696 |
|
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
697 |
def OnAddVariableButton(self, event): |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
698 |
self.Table.AppendRow(self.VariablesDefaultValue.copy()) |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
699 |
self.RefreshModel() |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
700 |
self.RefreshView() |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
701 |
event.Skip() |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
702 |
|
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
703 |
def OnDeleteVariableButton(self, event): |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
704 |
row = self.VariablesGrid.GetGridCursorRow() |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
705 |
self.Table.RemoveRow(row) |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
706 |
self.RefreshModel() |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
707 |
self.RefreshView() |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
708 |
event.Skip() |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
709 |
|
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
710 |
def OnUpVariableButton(self, event): |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
711 |
row = self.VariablesGrid.GetGridCursorRow() |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
712 |
self.Table.MoveRow(row, -1, self.VariablesGrid) |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
713 |
self.RefreshModel() |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
714 |
self.RefreshView() |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
715 |
event.Skip() |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
716 |
|
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
717 |
def OnDownVariableButton(self, event): |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
718 |
row = self.VariablesGrid.GetGridCursorRow() |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
719 |
self.Table.MoveRow(row, 1, self.VariablesGrid) |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
720 |
self.RefreshModel() |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
721 |
self.RefreshView() |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
722 |
event.Skip() |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
723 |
|
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
724 |
def OnVariablesGridCellChange(self, event): |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
725 |
self.RefreshModel() |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
726 |
self.RefreshView() |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
727 |
event.Skip() |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
728 |
|
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
729 |
def OnVariablesGridEditorShown(self, event): |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
730 |
row, col = event.GetRow(), event.GetCol() |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
731 |
if self.Table.GetColLabelValue(col) == "Type": |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
732 |
type_menu = wx.Menu(title='') |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
733 |
base_menu = wx.Menu(title='') |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
734 |
for base_type in self.Controler.GetBaseTypes(): |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
735 |
new_id = wx.NewId() |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
736 |
AppendMenu(base_menu, help='', id=new_id, kind=wx.ITEM_NORMAL, text=base_type) |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
737 |
self.Bind(wx.EVT_MENU, self.GetVariableTypeFunction(base_type), id=new_id) |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
738 |
type_menu.AppendMenu(wx.NewId(), "Base Types", base_menu) |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
739 |
datatype_menu = wx.Menu(title='') |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
740 |
for datatype in self.Controler.GetDataTypes(basetypes = False): |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
741 |
new_id = wx.NewId() |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
742 |
AppendMenu(datatype_menu, help='', id=new_id, kind=wx.ITEM_NORMAL, text=datatype) |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
743 |
self.Bind(wx.EVT_MENU, self.GetVariableTypeFunction(datatype), id=new_id) |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
744 |
type_menu.AppendMenu(wx.NewId(), "User Data Types", datatype_menu) |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
745 |
rect = self.VariablesGrid.BlockToDeviceRect((row, col), (row, col)) |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
746 |
self.VariablesGrid.PopupMenuXY(type_menu, rect.x + rect.width, rect.y + self.VariablesGrid.GetColLabelSize()) |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
747 |
event.Veto() |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
748 |
else: |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
749 |
event.Skip() |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
750 |
|
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
751 |
def GetVariableTypeFunction(self, base_type): |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
752 |
def VariableTypeFunction(event): |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
753 |
row = self.VariablesGrid.GetGridCursorRow() |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
754 |
self.Table.SetValueByName(row, "Type", base_type) |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
755 |
self.Table.ResetView(self.VariablesGrid) |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
756 |
self.RefreshModel() |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
757 |
self.RefreshView() |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
758 |
event.Skip() |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
759 |
return VariableTypeFunction |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
760 |
|
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
761 |
def OnVariablesGridCellLeftClick(self, event): |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
762 |
if event.GetCol() == 0: |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
763 |
row = event.GetRow() |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
764 |
num = 0 |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
765 |
if self.Table.GetValueByName(row, "Class") == "input": |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
766 |
dir = "%I" |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
767 |
for i in xrange(row): |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
768 |
if self.Table.GetValueByName(i, "Class") == "input": |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
769 |
num += 1 |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
770 |
else: |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
771 |
dir = "%Q" |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
772 |
for i in xrange(row): |
161 | 773 |
if self.Table.GetValueByName(i, "Class") == "output": |
145
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
774 |
num += 1 |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
775 |
data_type = self.Table.GetValueByName(row, "Type") |
401
8106a853a7c7
Adding support for displaying plugins available variable into Beremiz plugin tree
laurent
parents:
213
diff
changeset
|
776 |
var_name = self.Table.GetValueByName(row, "Name") |
145
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
777 |
base_location = ".".join(map(lambda x:str(x), self.Controler.GetCurrentLocation())) |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
778 |
location = "%s%s%s.%d"%(dir, self.Controler.GetSizeOfType(data_type), base_location, num) |
401
8106a853a7c7
Adding support for displaying plugins available variable into Beremiz plugin tree
laurent
parents:
213
diff
changeset
|
779 |
data = wx.TextDataObject(str((location, "location", data_type, var_name, ""))) |
145
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
780 |
dragSource = wx.DropSource(self.VariablesGrid) |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
781 |
dragSource.SetData(data) |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
782 |
dragSource.DoDragDrop() |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
783 |
event.Skip() |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
784 |
|
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
785 |
|
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
786 |
#------------------------------------------------------------------------------- |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
787 |
# SVGUIEditor Main Frame Class |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
788 |
#------------------------------------------------------------------------------- |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
789 |
|
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
790 |
|
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
791 |
CFILE_PARTS = ["Includes", "Variables", "Globals", "Init", "CleanUp", "Retrieve", |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
792 |
"Publish"] |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
793 |
|
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
794 |
[ID_CFILEEDITOR, ID_CFILEEDITORMAINSPLITTER, |
164 | 795 |
ID_CFILEEDITORCFILETREE, ID_CFILEEDITORPARTSOPENED, |
145
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
796 |
] = [wx.NewId() for _init_ctrls in range(4)] |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
797 |
|
213
d8dc1e51c3bf
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
185
diff
changeset
|
798 |
class CFileEditor(wx.Frame): |
145
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
799 |
|
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
800 |
if wx.VERSION < (2, 6, 0): |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
801 |
def Bind(self, event, function, id = None): |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
802 |
if id is not None: |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
803 |
event(self, id, function) |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
804 |
else: |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
805 |
event(self, function) |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
806 |
|
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
807 |
def _init_coll_EditMenu_Items(self, parent): |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
808 |
AppendMenu(parent, help='', id=wx.ID_REFRESH, |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
809 |
kind=wx.ITEM_NORMAL, text=u'Refresh\tCTRL+R') |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
810 |
AppendMenu(parent, help='', id=wx.ID_UNDO, |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
811 |
kind=wx.ITEM_NORMAL, text=u'Undo\tCTRL+Z') |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
812 |
AppendMenu(parent, help='', id=wx.ID_REDO, |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
813 |
kind=wx.ITEM_NORMAL, text=u'Redo\tCTRL+Y') |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
814 |
self.Bind(wx.EVT_MENU, self.OnRefreshMenu, id=wx.ID_REFRESH) |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
815 |
self.Bind(wx.EVT_MENU, self.OnUndoMenu, id=wx.ID_UNDO) |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
816 |
self.Bind(wx.EVT_MENU, self.OnRedoMenu, id=wx.ID_REDO) |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
817 |
|
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
818 |
def _init_coll_MenuBar_Menus(self, parent): |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
819 |
parent.Append(menu=self.EditMenu, title=u'&Edit') |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
820 |
|
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
821 |
def _init_utils(self): |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
822 |
self.MenuBar = wx.MenuBar() |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
823 |
|
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
824 |
self.EditMenu = wx.Menu(title='') |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
825 |
|
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
826 |
self._init_coll_MenuBar_Menus(self.MenuBar) |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
827 |
self._init_coll_EditMenu_Items(self.EditMenu) |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
828 |
|
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
829 |
def _init_ctrls(self, prnt): |
213
d8dc1e51c3bf
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
185
diff
changeset
|
830 |
wx.Frame.__init__(self, id=ID_CFILEEDITOR, name=u'CFileEditor', |
d8dc1e51c3bf
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
185
diff
changeset
|
831 |
parent=prnt, pos=wx.DefaultPosition, size=wx.Size(800, 650), |
d8dc1e51c3bf
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
185
diff
changeset
|
832 |
style=wx.DEFAULT_FRAME_STYLE, title=u'CFileEditor') |
145
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
833 |
self._init_utils() |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
834 |
self.SetClientSize(wx.Size(1000, 600)) |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
835 |
self.SetMenuBar(self.MenuBar) |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
836 |
self.Bind(wx.EVT_CLOSE, self.OnCloseFrame) |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
837 |
|
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
838 |
self.Bind(wx.EVT_MENU, self.OnSaveMenu, id=wx.ID_SAVE) |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
839 |
accel = wx.AcceleratorTable([wx.AcceleratorEntry(wx.ACCEL_CTRL, 83, wx.ID_SAVE)]) |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
840 |
self.SetAcceleratorTable(accel) |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
841 |
|
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
842 |
if wx.VERSION >= (2, 8, 0): |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
843 |
self.AUIManager = wx.aui.AuiManager(self) |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
844 |
self.AUIManager.SetDockSizeConstraint(0.5, 0.5) |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
845 |
|
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
846 |
if wx.VERSION < (2, 8, 0): |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
847 |
self.MainSplitter = wx.SplitterWindow(id=ID_CFILEEDITORMAINSPLITTER, |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
848 |
name='MainSplitter', parent=self, point=wx.Point(0, 0), |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
849 |
size=wx.Size(-1, -1), style=wx.SP_3D) |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
850 |
self.MainSplitter.SetNeedUpdating(True) |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
851 |
self.MainSplitter.SetMinimumPaneSize(1) |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
852 |
|
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
853 |
self.CFileTree = wx.TreeCtrl(id=ID_CFILEEDITORCFILETREE, |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
854 |
name='CFileTree', parent=self.MainSplitter, pos=wx.Point(0, 0), |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
855 |
size=wx.Size(-1, -1), style=wx.TR_HAS_BUTTONS|wx.TR_SINGLE|wx.SUNKEN_BORDER) |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
856 |
else: |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
857 |
self.CFileTree = wx.TreeCtrl(id=ID_CFILEEDITORCFILETREE, |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
858 |
name='CFileTree', parent=self, pos=wx.Point(0, 0), |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
859 |
size=wx.Size(-1, -1), style=wx.TR_HAS_BUTTONS|wx.TR_SINGLE|wx.SUNKEN_BORDER) |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
860 |
self.AUIManager.AddPane(self.CFileTree, wx.aui.AuiPaneInfo().Caption("CFile Tree").Left().Layer(1).BestSize(wx.Size(200, 500)).CloseButton(False)) |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
861 |
self.Bind(wx.EVT_TREE_SEL_CHANGED, self.OnCFileTreeItemSelected, |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
862 |
id=ID_CFILEEDITORCFILETREE) |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
863 |
self.Bind(wx.EVT_TREE_ITEM_ACTIVATED, self.OnCFileTreeItemActivated, |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
864 |
id=ID_CFILEEDITORCFILETREE) |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
865 |
|
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
866 |
if wx.VERSION < (2, 8, 0): |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
867 |
self.PartsOpened = wx.Notebook(id=ID_CFILEEDITORPARTSOPENED, |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
868 |
name='PartsOpened', parent=self.MainSplitter, pos=wx.Point(0, |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
869 |
0), size=wx.Size(0, 0), style=0) |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
870 |
if wx.VERSION >= (2, 6, 0): |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
871 |
self.PartsOpened.Bind(wx.EVT_NOTEBOOK_PAGE_CHANGED, |
164 | 872 |
self.OnPartSelectedChanged, id=ID_CFILEEDITORPARTSOPENED) |
873 |
else: |
|
874 |
wx.EVT_NOTEBOOK_PAGE_CHANGED(self.PartsOpened, ID_CFILEEDITORPARTSOPENED, |
|
145
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
875 |
self.OnPartSelectedChanged) |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
876 |
|
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
877 |
self.MainSplitter.SplitVertically(self.ProjectTree, self.PartsOpened, 200) |
213
d8dc1e51c3bf
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
185
diff
changeset
|
878 |
else: |
d8dc1e51c3bf
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
185
diff
changeset
|
879 |
self.PartsOpened = wx.aui.AuiNotebook(self) |
d8dc1e51c3bf
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
185
diff
changeset
|
880 |
self.PartsOpened.Bind(wx.aui.EVT_AUINOTEBOOK_PAGE_CHANGED, |
d8dc1e51c3bf
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
185
diff
changeset
|
881 |
self.OnPartSelectedChanged) |
d8dc1e51c3bf
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
185
diff
changeset
|
882 |
self.AUIManager.AddPane(self.PartsOpened, wx.aui.AuiPaneInfo().CentrePane()) |
d8dc1e51c3bf
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
185
diff
changeset
|
883 |
|
145
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
884 |
self.StatusBar = wx.StatusBar( name='HelpBar', |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
885 |
parent=self, style=wx.ST_SIZEGRIP) |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
886 |
self.SetStatusBar(self.StatusBar) |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
887 |
|
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
888 |
if wx.VERSION >= (2, 8, 0): |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
889 |
self.AUIManager.Update() |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
890 |
|
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
891 |
def __init__(self, parent, controler): |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
892 |
self._init_ctrls(parent) |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
893 |
|
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
894 |
self.Controler = controler |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
895 |
|
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
896 |
self.InitCFileTree() |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
897 |
self.RefreshTitle() |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
898 |
self.RefreshEditMenu() |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
899 |
|
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
900 |
def OnCloseFrame(self, event): |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
901 |
if wx.VERSION >= (2, 8, 0): |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
902 |
self.AUIManager.UnInit() |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
903 |
if getattr(self, "_onclose", None) is not None: |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
904 |
self._onclose() |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
905 |
event.Skip() |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
906 |
|
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
907 |
def OnCloseTabMenu(self, event): |
213
d8dc1e51c3bf
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
185
diff
changeset
|
908 |
selected = self.PartsOpened.GetSelection() |
145
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
909 |
if selected >= 0: |
213
d8dc1e51c3bf
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
185
diff
changeset
|
910 |
self.PartsOpened.DeletePage(selected) |
145
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
911 |
event.Skip() |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
912 |
|
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
913 |
def OnSaveMenu(self, event): |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
914 |
if getattr(self, "_onsave", None) != None: |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
915 |
self._onsave() |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
916 |
self.RefreshTitle() |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
917 |
self.RefreshEditMenu() |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
918 |
event.Skip() |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
919 |
|
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
920 |
#------------------------------------------------------------------------------- |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
921 |
# Notebook Unified Functions |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
922 |
#------------------------------------------------------------------------------- |
213
d8dc1e51c3bf
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
185
diff
changeset
|
923 |
|
145
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
924 |
def DeleteAllPages(self): |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
925 |
if wx.VERSION >= (2, 8, 0): |
213
d8dc1e51c3bf
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
185
diff
changeset
|
926 |
for idx in xrange(self.PartsOpened.GetPageCount()): |
d8dc1e51c3bf
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
185
diff
changeset
|
927 |
self.PartsOpened.DeletePage(0) |
145
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
928 |
else: |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
929 |
self.PartsOpened.DeleteAllPages() |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
930 |
|
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
931 |
def SetPageBitmap(self, idx, bitmap): |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
932 |
if wx.VERSION >= (2, 8, 0): |
213
d8dc1e51c3bf
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
185
diff
changeset
|
933 |
return self.PartsOpened.SetPageBitmap(idx, bitmap) |
145
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
934 |
else: |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
935 |
return self.PartsOpened.SetPageImage(idx, bitmap) |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
936 |
|
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
937 |
def IsOpened(self, name): |
213
d8dc1e51c3bf
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
185
diff
changeset
|
938 |
for idx in xrange(self.PartsOpened.GetPageCount()): |
d8dc1e51c3bf
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
185
diff
changeset
|
939 |
if self.PartsOpened.GetPage(idx).IsViewing(name): |
145
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
940 |
return idx |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
941 |
return None |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
942 |
|
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
943 |
def RefreshTitle(self): |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
944 |
self.SetTitle("CFileEditor - %s"%self.Controler.GetFilename()) |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
945 |
|
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
946 |
#------------------------------------------------------------------------------- |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
947 |
# Edit Project Menu Functions |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
948 |
#------------------------------------------------------------------------------- |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
949 |
|
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
950 |
def RefreshEditMenu(self): |
185 | 951 |
undo, redo = self.Controler.GetBufferState() |
952 |
self.EditMenu.Enable(wx.ID_UNDO, undo) |
|
953 |
self.EditMenu.Enable(wx.ID_REDO, redo) |
|
145
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
954 |
|
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
955 |
def OnRefreshMenu(self, event): |
213
d8dc1e51c3bf
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
185
diff
changeset
|
956 |
selected = self.PartsOpened.GetSelection() |
145
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
957 |
if selected != -1: |
213
d8dc1e51c3bf
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
185
diff
changeset
|
958 |
window = self.PartsOpened.GetPage(selected) |
145
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
959 |
window.RefreshView() |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
960 |
event.Skip() |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
961 |
|
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
962 |
def OnUndoMenu(self, event): |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
963 |
self.Controler.LoadPrevious() |
213
d8dc1e51c3bf
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
185
diff
changeset
|
964 |
selected = self.PartsOpened.GetSelection() |
145
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
965 |
if selected != -1: |
213
d8dc1e51c3bf
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
185
diff
changeset
|
966 |
window = self.PartsOpened.GetPage(selected) |
145
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
967 |
window.RefreshView() |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
968 |
self.RefreshTitle() |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
969 |
self.RefreshEditMenu() |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
970 |
event.Skip() |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
971 |
|
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
972 |
def OnRedoMenu(self, event): |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
973 |
self.Controler.LoadNext() |
213
d8dc1e51c3bf
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
185
diff
changeset
|
974 |
selected = self.PartsOpened.GetSelection() |
145
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
975 |
if selected != -1: |
213
d8dc1e51c3bf
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
185
diff
changeset
|
976 |
window = self.PartsOpened.GetPage(selected) |
145
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
977 |
window.RefreshView() |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
978 |
self.RefreshTitle() |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
979 |
self.RefreshEditMenu() |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
980 |
event.Skip() |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
981 |
|
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
982 |
#------------------------------------------------------------------------------- |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
983 |
# CFile Editor Panels Management Functions |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
984 |
#------------------------------------------------------------------------------- |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
985 |
|
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
986 |
def OnPartSelectedChanged(self, event): |
213
d8dc1e51c3bf
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
185
diff
changeset
|
987 |
old_selected = self.PartsOpened.GetSelection() |
d8dc1e51c3bf
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
185
diff
changeset
|
988 |
if old_selected >= 0: |
d8dc1e51c3bf
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
185
diff
changeset
|
989 |
self.PartsOpened.GetPage(old_selected).ResetBuffer() |
d8dc1e51c3bf
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
185
diff
changeset
|
990 |
selected = event.GetSelection() |
d8dc1e51c3bf
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
185
diff
changeset
|
991 |
if selected >= 0: |
d8dc1e51c3bf
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
185
diff
changeset
|
992 |
window = self.PartsOpened.GetPage(selected) |
d8dc1e51c3bf
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
185
diff
changeset
|
993 |
window.RefreshView() |
145
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
994 |
event.Skip() |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
995 |
|
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
996 |
#------------------------------------------------------------------------------- |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
997 |
# CFile Tree Management Functions |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
998 |
#------------------------------------------------------------------------------- |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
999 |
|
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
1000 |
def InitCFileTree(self): |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
1001 |
root = self.CFileTree.AddRoot("C File") |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
1002 |
for name in CFILE_PARTS: |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
1003 |
self.CFileTree.AppendItem(root, name) |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
1004 |
self.CFileTree.Expand(root) |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
1005 |
|
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
1006 |
def OnCFileTreeItemActivated(self, event): |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
1007 |
self.EditCFilePart(self.CFileTree.GetItemText(event.GetItem())) |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
1008 |
event.Skip() |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
1009 |
|
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
1010 |
def OnCFileTreeItemSelected(self, event): |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
1011 |
select_item = event.GetItem() |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
1012 |
self.EditCFilePart(self.CFileTree.GetItemText(event.GetItem()), True) |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
1013 |
event.Skip() |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
1014 |
|
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
1015 |
def EditCFilePart(self, name, onlyopened = False): |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
1016 |
openedidx = self.IsOpened(name) |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
1017 |
if openedidx is not None: |
213
d8dc1e51c3bf
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
185
diff
changeset
|
1018 |
old_selected = self.PartsOpened.GetSelection() |
145
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
1019 |
if old_selected != openedidx: |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
1020 |
if old_selected >= 0: |
213
d8dc1e51c3bf
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
185
diff
changeset
|
1021 |
self.PartsOpened.GetPage(old_selected).ResetBuffer() |
d8dc1e51c3bf
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
185
diff
changeset
|
1022 |
self.PartsOpened.SetSelection(openedidx) |
d8dc1e51c3bf
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
185
diff
changeset
|
1023 |
self.PartsOpened.GetPage(openedidx).RefreshView() |
145
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
1024 |
elif not onlyopened: |
213
d8dc1e51c3bf
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
185
diff
changeset
|
1025 |
if name == "Variables": |
d8dc1e51c3bf
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
185
diff
changeset
|
1026 |
new_window = VariablesEditor(self.PartsOpened, self, self.Controler) |
d8dc1e51c3bf
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
185
diff
changeset
|
1027 |
self.PartsOpened.AddPage(new_window, name) |
145
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
1028 |
else: |
213
d8dc1e51c3bf
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
185
diff
changeset
|
1029 |
new_window = CppEditor(self.PartsOpened, name, self, self.Controler) |
d8dc1e51c3bf
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
185
diff
changeset
|
1030 |
self.PartsOpened.AddPage(new_window, name) |
145
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
1031 |
openedidx = self.IsOpened(name) |
213
d8dc1e51c3bf
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
185
diff
changeset
|
1032 |
old_selected = self.PartsOpened.GetSelection() |
145
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
1033 |
if old_selected != openedidx: |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
1034 |
if old_selected >= 0: |
213
d8dc1e51c3bf
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
185
diff
changeset
|
1035 |
self.PartsOpened.GetPage(old_selected).ResetBuffer() |
d8dc1e51c3bf
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
185
diff
changeset
|
1036 |
for i in xrange(self.PartsOpened.GetPageCount()): |
d8dc1e51c3bf
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
185
diff
changeset
|
1037 |
window = self.PartsOpened.GetPage(i) |
145
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
1038 |
if window.IsViewing(name): |
213
d8dc1e51c3bf
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
185
diff
changeset
|
1039 |
self.PartsOpened.SetSelection(i) |
145
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
1040 |
window.RefreshView() |
94855f7b08a9
Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff
changeset
|
1041 |
window.SetFocus() |