author | Edouard Tisserant |
Sat, 19 May 2012 15:54:16 +0200 | |
changeset 732 | c4b0f117e106 |
parent 721 | ecf4d203c4d4 |
child 734 | 5c42cafaee15 |
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 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
|
2 |
|
630
91b2ae63ea3d
Including external tools for editing plugin informations into Beremiz window
laurent
parents:
626
diff
changeset
|
3 |
import wx |
91b2ae63ea3d
Including external tools for editing plugin informations into Beremiz window
laurent
parents:
626
diff
changeset
|
4 |
import wx.grid |
91b2ae63ea3d
Including external tools for editing plugin informations into Beremiz window
laurent
parents:
626
diff
changeset
|
5 |
import wx.stc as stc |
91b2ae63ea3d
Including external tools for editing plugin informations into Beremiz window
laurent
parents:
626
diff
changeset
|
6 |
import wx.lib.buttons |
91b2ae63ea3d
Including external tools for editing plugin informations into Beremiz window
laurent
parents:
626
diff
changeset
|
7 |
|
651
cbeb769b0a56
Adding support for unifying grid table control elements
laurent
parents:
637
diff
changeset
|
8 |
from controls import CustomGrid, CustomTable, EditorPanel |
626
2b9bd5dcf8d2
Adding support for using keyboard to edit cfile interface variables displayed in Grid
laurent
parents:
610
diff
changeset
|
9 |
|
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
|
10 |
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
|
11 |
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
|
12 |
'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
|
13 |
'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
|
14 |
'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
|
15 |
'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
|
16 |
'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
|
17 |
} |
94855f7b08a9
Improving c_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 |
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
|
19 |
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
|
20 |
'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
|
21 |
'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
|
22 |
'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
|
23 |
'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
|
24 |
'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
|
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
|
26 |
|
94855f7b08a9
Improving c_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 |
|
94855f7b08a9
Improving c_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 |
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
|
29 |
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
|
30 |
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
|
31 |
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
|
32 |
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
|
33 |
|
94855f7b08a9
Improving c_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 |
|
94855f7b08a9
Improving c_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 |
[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
|
36 |
] = [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
|
37 |
|
94855f7b08a9
Improving c_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 |
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
|
39 |
"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
|
40 |
"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
|
41 |
"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
|
42 |
"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
|
43 |
"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
|
44 |
"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
|
45 |
"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
|
46 |
"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
|
47 |
|
94855f7b08a9
Improving c_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 |
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
|
49 |
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
|
50 |
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
|
51 |
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
|
52 |
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
|
53 |
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
|
54 |
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
|
55 |
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
|
56 |
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
|
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 + 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
|
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 + 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
|
61 |
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
|
62 |
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
|
63 |
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
|
64 |
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
|
65 |
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
|
66 |
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
|
67 |
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
|
68 |
|
94855f7b08a9
Improving c_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 |
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
|
70 |
|
94855f7b08a9
Improving c_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 |
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
|
72 |
|
94855f7b08a9
Improving c_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 |
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
|
74 |
stc.StyledTextCtrl.__init__(self, parent, ID_CPPEDITOR, wx.DefaultPosition, |
630
91b2ae63ea3d
Including external tools for editing plugin informations into Beremiz window
laurent
parents:
626
diff
changeset
|
75 |
wx.Size(0, 0), 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
|
76 |
|
94855f7b08a9
Improving c_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 |
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
|
78 |
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
|
79 |
|
94855f7b08a9
Improving c_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 |
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
|
81 |
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
|
82 |
|
94855f7b08a9
Improving c_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.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
|
84 |
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
|
85 |
|
94855f7b08a9
Improving c_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.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
|
87 |
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
|
88 |
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
|
89 |
|
94855f7b08a9
Improving c_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 |
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
|
91 |
#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
|
92 |
#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
|
93 |
#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
|
94 |
#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
|
95 |
|
94855f7b08a9
Improving c_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.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
|
97 |
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
|
98 |
|
94855f7b08a9
Improving c_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 |
# 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
|
100 |
#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
|
101 |
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
|
102 |
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
|
103 |
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
|
104 |
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
|
105 |
|
94855f7b08a9
Improving c_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 |
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
|
107 |
# 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
|
108 |
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
|
109 |
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
|
110 |
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
|
111 |
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
|
112 |
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
|
113 |
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
|
114 |
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
|
115 |
|
94855f7b08a9
Improving c_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 |
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
|
117 |
# 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
|
118 |
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
|
119 |
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
|
120 |
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
|
121 |
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
|
122 |
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
|
123 |
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
|
124 |
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
|
125 |
|
94855f7b08a9
Improving c_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 |
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
|
127 |
# 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
|
128 |
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
|
129 |
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
|
130 |
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
|
131 |
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
|
132 |
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
|
133 |
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
|
134 |
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
|
135 |
|
94855f7b08a9
Improving c_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 |
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
|
137 |
# 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
|
138 |
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
|
139 |
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
|
140 |
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
|
141 |
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
|
142 |
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
|
143 |
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
|
144 |
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
|
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 |
|
94855f7b08a9
Improving c_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 |
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
|
148 |
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
|
149 |
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
|
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
|
151 |
# 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
|
152 |
# 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
|
153 |
# 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
|
154 |
|
94855f7b08a9
Improving c_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 |
# 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
|
156 |
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
|
157 |
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
|
158 |
|
94855f7b08a9
Improving c_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 |
# 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
|
160 |
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
|
161 |
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
|
162 |
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
|
163 |
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
|
164 |
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
|
165 |
|
94855f7b08a9
Improving c_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_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
|
167 |
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
|
168 |
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
|
169 |
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
|
170 |
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
|
171 |
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
|
172 |
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
|
173 |
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
|
174 |
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
|
175 |
|
94855f7b08a9
Improving c_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 |
# 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
|
177 |
#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
|
178 |
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
|
179 |
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
|
180 |
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
|
181 |
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
|
182 |
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
|
183 |
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
|
184 |
|
94855f7b08a9
Improving c_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 |
# 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
|
186 |
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
|
187 |
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
|
188 |
|
94855f7b08a9
Improving c_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.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
|
190 |
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
|
191 |
|
94855f7b08a9
Improving c_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 |
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
|
193 |
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
|
194 |
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
|
195 |
|
94855f7b08a9
Improving c_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 |
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
|
197 |
|
94855f7b08a9
Improving c_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 |
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
|
199 |
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
|
200 |
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
|
201 |
|
94855f7b08a9
Improving c_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 |
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
|
203 |
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
|
204 |
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
|
205 |
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
|
206 |
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
|
207 |
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
|
208 |
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
|
209 |
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
|
210 |
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
|
211 |
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
|
212 |
self.CurrentAction = ("Add", event.GetPosition()) |
658 | 213 |
wx.CallAfter(self.RefreshModel) |
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
|
214 |
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
|
215 |
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
|
216 |
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
|
217 |
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
|
218 |
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
|
219 |
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
|
220 |
self.CurrentAction = ("Delete", event.GetPosition()) |
658 | 221 |
wx.CallAfter(self.RefreshModel) |
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
|
222 |
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
|
223 |
|
94855f7b08a9
Improving c_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 |
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
|
225 |
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
|
226 |
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
|
227 |
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
|
228 |
|
94855f7b08a9
Improving c_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 |
# 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
|
230 |
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
|
231 |
self.Controler.BufferCFile() |
658 | 232 |
if self.ParentWindow is not None: |
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
|
233 |
self.ParentWindow.RefreshTitle() |
587 | 234 |
self.ParentWindow.RefreshFileMenu() |
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
|
235 |
self.ParentWindow.RefreshEditMenu() |
630
91b2ae63ea3d
Including external tools for editing plugin informations into Beremiz window
laurent
parents:
626
diff
changeset
|
236 |
self.ParentWindow.RefreshPageTitles() |
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
|
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 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
|
239 |
self.Controler.StartBuffering() |
658 | 240 |
if self.ParentWindow is not None: |
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
|
241 |
self.ParentWindow.RefreshTitle() |
587 | 242 |
self.ParentWindow.RefreshFileMenu() |
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
|
243 |
self.ParentWindow.RefreshEditMenu() |
630
91b2ae63ea3d
Including external tools for editing plugin informations into Beremiz window
laurent
parents:
626
diff
changeset
|
244 |
self.ParentWindow.RefreshPageTitles() |
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
|
245 |
|
94855f7b08a9
Improving c_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 |
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
|
247 |
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
|
248 |
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
|
249 |
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
|
250 |
|
94855f7b08a9
Improving c_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 |
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
|
252 |
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
|
253 |
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
|
254 |
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
|
255 |
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
|
256 |
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
|
257 |
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
|
258 |
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
|
259 |
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
|
260 |
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
|
261 |
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
|
262 |
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
|
263 |
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
|
264 |
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
|
265 |
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
|
266 |
|
94855f7b08a9
Improving c_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 |
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
|
268 |
|
630
91b2ae63ea3d
Including external tools for editing plugin informations into Beremiz window
laurent
parents:
626
diff
changeset
|
269 |
def DoGetBestSize(self): |
91b2ae63ea3d
Including external tools for editing plugin informations into Beremiz window
laurent
parents:
626
diff
changeset
|
270 |
return self.ParentWindow.GetPanelBestSize() |
91b2ae63ea3d
Including external tools for editing plugin informations into Beremiz window
laurent
parents:
626
diff
changeset
|
271 |
|
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
|
272 |
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
|
273 |
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
|
274 |
|
94855f7b08a9
Improving c_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 |
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
|
276 |
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
|
277 |
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
|
278 |
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
|
279 |
|
94855f7b08a9
Improving c_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 |
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
|
281 |
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
|
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 |
# 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
|
284 |
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
|
285 |
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
|
286 |
## 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
|
287 |
## 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
|
288 |
## '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
|
289 |
## '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
|
290 |
# 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
|
291 |
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
|
292 |
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
|
293 |
|
94855f7b08a9
Improving c_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 |
# 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
|
295 |
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
|
296 |
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
|
297 |
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
|
298 |
|
94855f7b08a9
Improving c_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 |
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
|
300 |
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
|
301 |
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
|
302 |
|
94855f7b08a9
Improving c_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 |
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
|
304 |
# 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
|
305 |
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
|
306 |
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
|
307 |
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
|
308 |
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
|
309 |
|
94855f7b08a9
Improving c_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 |
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
|
311 |
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
|
312 |
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
|
313 |
|
94855f7b08a9
Improving c_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 |
# 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
|
315 |
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
|
316 |
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
|
317 |
|
94855f7b08a9
Improving c_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 |
# 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
|
319 |
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
|
320 |
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
|
321 |
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
|
322 |
|
94855f7b08a9
Improving c_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 |
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
|
324 |
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
|
325 |
|
94855f7b08a9
Improving c_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 |
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
|
327 |
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
|
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 |
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
|
330 |
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
|
331 |
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
|
332 |
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
|
333 |
#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
|
334 |
#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
|
335 |
#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
|
336 |
#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
|
337 |
|
94855f7b08a9
Improving c_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 |
|
94855f7b08a9
Improving c_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 |
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
|
340 |
# 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
|
341 |
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
|
342 |
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
|
343 |
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
|
344 |
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
|
345 |
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
|
346 |
|
94855f7b08a9
Improving c_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 |
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
|
348 |
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
|
349 |
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
|
350 |
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
|
351 |
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
|
352 |
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
|
353 |
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
|
354 |
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
|
355 |
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
|
356 |
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
|
357 |
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
|
358 |
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
|
359 |
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
|
360 |
|
94855f7b08a9
Improving c_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 |
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
|
363 |
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
|
364 |
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
|
365 |
|
94855f7b08a9
Improving c_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 |
# 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
|
367 |
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
|
368 |
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
|
369 |
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
|
370 |
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
|
371 |
|
94855f7b08a9
Improving c_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 = 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
|
373 |
|
94855f7b08a9
Improving c_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 |
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
|
375 |
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
|
376 |
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
|
377 |
(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
|
378 |
|
94855f7b08a9
Improving c_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 |
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
|
380 |
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
|
381 |
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
|
382 |
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
|
383 |
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
|
384 |
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
|
385 |
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
|
386 |
|
94855f7b08a9
Improving c_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 |
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
|
388 |
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
|
389 |
|
94855f7b08a9
Improving c_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 |
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
|
391 |
|
94855f7b08a9
Improving c_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 |
|
94855f7b08a9
Improving c_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 |
|
94855f7b08a9
Improving c_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 |
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
|
395 |
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
|
396 |
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
|
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 |
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
|
399 |
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
|
400 |
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
|
401 |
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
|
402 |
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
|
403 |
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
|
404 |
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
|
405 |
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
|
406 |
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
|
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 |
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
|
409 |
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
|
410 |
|
94855f7b08a9
Improving c_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 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
|
412 |
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
|
413 |
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
|
414 |
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
|
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 |
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
|
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 |
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
|
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 |
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
|
421 |
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
|
422 |
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
|
423 |
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
|
424 |
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
|
425 |
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
|
426 |
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
|
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 |
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
|
429 |
|
637
c19557ec2c5a
Fixing bug preventing copy/cut/paste using shortcuts on CFileEditor text editors
laurent
parents:
630
diff
changeset
|
430 |
def Cut(self): |
c19557ec2c5a
Fixing bug preventing copy/cut/paste using shortcuts on CFileEditor text editors
laurent
parents:
630
diff
changeset
|
431 |
self.ResetBuffer() |
c19557ec2c5a
Fixing bug preventing copy/cut/paste using shortcuts on CFileEditor text editors
laurent
parents:
630
diff
changeset
|
432 |
self.DisableEvents = True |
c19557ec2c5a
Fixing bug preventing copy/cut/paste using shortcuts on CFileEditor text editors
laurent
parents:
630
diff
changeset
|
433 |
self.CmdKeyExecute(wx.stc.STC_CMD_CUT) |
c19557ec2c5a
Fixing bug preventing copy/cut/paste using shortcuts on CFileEditor text editors
laurent
parents:
630
diff
changeset
|
434 |
self.DisableEvents = False |
c19557ec2c5a
Fixing bug preventing copy/cut/paste using shortcuts on CFileEditor text editors
laurent
parents:
630
diff
changeset
|
435 |
self.RefreshModel() |
c19557ec2c5a
Fixing bug preventing copy/cut/paste using shortcuts on CFileEditor text editors
laurent
parents:
630
diff
changeset
|
436 |
self.RefreshBuffer() |
c19557ec2c5a
Fixing bug preventing copy/cut/paste using shortcuts on CFileEditor text editors
laurent
parents:
630
diff
changeset
|
437 |
|
c19557ec2c5a
Fixing bug preventing copy/cut/paste using shortcuts on CFileEditor text editors
laurent
parents:
630
diff
changeset
|
438 |
def Copy(self): |
c19557ec2c5a
Fixing bug preventing copy/cut/paste using shortcuts on CFileEditor text editors
laurent
parents:
630
diff
changeset
|
439 |
self.CmdKeyExecute(wx.stc.STC_CMD_COPY) |
c19557ec2c5a
Fixing bug preventing copy/cut/paste using shortcuts on CFileEditor text editors
laurent
parents:
630
diff
changeset
|
440 |
|
c19557ec2c5a
Fixing bug preventing copy/cut/paste using shortcuts on CFileEditor text editors
laurent
parents:
630
diff
changeset
|
441 |
def Paste(self): |
c19557ec2c5a
Fixing bug preventing copy/cut/paste using shortcuts on CFileEditor text editors
laurent
parents:
630
diff
changeset
|
442 |
self.ResetBuffer() |
c19557ec2c5a
Fixing bug preventing copy/cut/paste using shortcuts on CFileEditor text editors
laurent
parents:
630
diff
changeset
|
443 |
self.DisableEvents = True |
c19557ec2c5a
Fixing bug preventing copy/cut/paste using shortcuts on CFileEditor text editors
laurent
parents:
630
diff
changeset
|
444 |
self.CmdKeyExecute(wx.stc.STC_CMD_PASTE) |
c19557ec2c5a
Fixing bug preventing copy/cut/paste using shortcuts on CFileEditor text editors
laurent
parents:
630
diff
changeset
|
445 |
self.DisableEvents = False |
c19557ec2c5a
Fixing bug preventing copy/cut/paste using shortcuts on CFileEditor text editors
laurent
parents:
630
diff
changeset
|
446 |
self.RefreshModel() |
c19557ec2c5a
Fixing bug preventing copy/cut/paste using shortcuts on CFileEditor text editors
laurent
parents:
630
diff
changeset
|
447 |
self.RefreshBuffer() |
c19557ec2c5a
Fixing bug preventing copy/cut/paste using shortcuts on CFileEditor text editors
laurent
parents:
630
diff
changeset
|
448 |
|
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
|
449 |
|
94855f7b08a9
Improving c_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 |
#------------------------------------------------------------------------------- |
94855f7b08a9
Improving c_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 |
# 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
|
452 |
#------------------------------------------------------------------------------- |
94855f7b08a9
Improving c_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 |
|
651
cbeb769b0a56
Adding support for unifying grid table control elements
laurent
parents:
637
diff
changeset
|
454 |
class VariablesTable(CustomTable): |
cbeb769b0a56
Adding support for unifying grid table control elements
laurent
parents:
637
diff
changeset
|
455 |
|
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
|
456 |
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
|
457 |
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
|
458 |
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
|
459 |
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
|
460 |
else: |
651
cbeb769b0a56
Adding support for unifying grid table control elements
laurent
parents:
637
diff
changeset
|
461 |
return str(self.data[row].get(self.GetColLabelValue(col, False), "")) |
cbeb769b0a56
Adding support for unifying grid table control elements
laurent
parents:
637
diff
changeset
|
462 |
|
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
|
463 |
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
|
464 |
""" |
94855f7b08a9
Improving c_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 |
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
|
466 |
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
|
467 |
|
94855f7b08a9
Improving c_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 |
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
|
469 |
""" |
94855f7b08a9
Improving c_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 |
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
|
472 |
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
|
473 |
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
|
474 |
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
|
475 |
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
|
476 |
renderer = None |
665
aec7aca89f3e
Fixing bug in c_ext plugin variable grid cells not editable
laurent
parents:
658
diff
changeset
|
477 |
colname = self.GetColLabelValue(col, False) |
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
|
478 |
|
94855f7b08a9
Improving c_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 |
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
|
480 |
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
|
481 |
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
|
482 |
editor = wx.grid.GridCellChoiceEditor() |
603
e1ef99c609eb
added memory location support to C file pluguin
Edouard Tisserant
parents:
587
diff
changeset
|
483 |
editor.SetParameters("input,memory,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
|
484 |
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
|
485 |
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
|
486 |
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
|
487 |
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
|
488 |
|
94855f7b08a9
Improving c_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 |
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
|
490 |
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
|
491 |
|
94855f7b08a9
Improving c_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.SetCellBackgroundColour(row, col, wx.WHITE) |
651
cbeb769b0a56
Adding support for unifying grid table control elements
laurent
parents:
637
diff
changeset
|
493 |
self.ResizeRow(grid, row) |
cbeb769b0a56
Adding support for unifying grid table control elements
laurent
parents:
637
diff
changeset
|
494 |
|
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
|
495 |
|
94855f7b08a9
Improving c_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 |
[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
|
497 |
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
|
498 |
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
|
499 |
] = [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
|
500 |
|
94855f7b08a9
Improving c_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 |
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
|
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 |
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
|
504 |
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
|
505 |
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
|
506 |
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
|
507 |
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
|
508 |
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
|
509 |
|
94855f7b08a9
Improving c_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 |
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
|
511 |
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
|
512 |
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
|
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 |
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
|
515 |
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
|
516 |
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
|
517 |
|
94855f7b08a9
Improving c_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 |
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
|
519 |
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
|
520 |
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
|
521 |
|
94855f7b08a9
Improving c_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 |
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
|
523 |
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
|
524 |
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
|
525 |
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
|
526 |
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
|
527 |
|
94855f7b08a9
Improving c_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 |
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
|
529 |
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
|
530 |
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
|
531 |
|
94855f7b08a9
Improving c_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 |
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
|
533 |
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
|
534 |
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
|
535 |
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
|
536 |
|
94855f7b08a9
Improving c_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 |
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
|
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 |
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
|
540 |
wx.Panel.__init__(self, id=ID_VARIABLESEDITOR, name='', parent=prnt, |
630
91b2ae63ea3d
Including external tools for editing plugin informations into Beremiz window
laurent
parents:
626
diff
changeset
|
541 |
size=wx.Size(0, 0), style=wx.TAB_TRAVERSAL) |
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
|
542 |
|
626
2b9bd5dcf8d2
Adding support for using keyboard to edit cfile interface variables displayed in Grid
laurent
parents:
610
diff
changeset
|
543 |
self.VariablesGrid = CustomGrid(id=ID_VARIABLESEDITORVARIABLESGRID, |
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
|
544 |
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
|
545 |
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
|
546 |
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
|
547 |
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
|
548 |
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
|
549 |
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
|
550 |
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
|
551 |
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
|
552 |
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
|
553 |
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
|
554 |
|
94855f7b08a9
Improving c_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 |
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
|
556 |
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
|
557 |
size=wx.Size(122, 32), style=0) |
626
2b9bd5dcf8d2
Adding support for using keyboard to edit cfile interface variables displayed in Grid
laurent
parents:
610
diff
changeset
|
558 |
|
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
|
559 |
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
|
560 |
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
|
561 |
size=wx.Size(122, 32), style=0) |
626
2b9bd5dcf8d2
Adding support for using keyboard to edit cfile interface variables displayed in Grid
laurent
parents:
610
diff
changeset
|
562 |
|
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
|
563 |
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
|
564 |
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
|
565 |
size=wx.Size(32, 32), style=0) |
626
2b9bd5dcf8d2
Adding support for using keyboard to edit cfile interface variables displayed in Grid
laurent
parents:
610
diff
changeset
|
566 |
|
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
|
567 |
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
|
568 |
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
|
569 |
size=wx.Size(32, 32), style=0) |
626
2b9bd5dcf8d2
Adding support for using keyboard to edit cfile interface variables displayed in Grid
laurent
parents:
610
diff
changeset
|
570 |
|
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
|
571 |
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
|
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 |
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
|
574 |
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
|
575 |
|
94855f7b08a9
Improving c_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 |
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
|
577 |
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
|
578 |
|
94855f7b08a9
Improving c_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 |
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
|
580 |
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
|
581 |
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
|
582 |
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
|
583 |
self.VariablesGrid.SetTable(self.Table) |
626
2b9bd5dcf8d2
Adding support for using keyboard to edit cfile interface variables displayed in Grid
laurent
parents:
610
diff
changeset
|
584 |
self.VariablesGrid.SetButtons({"Add": self.AddVariableButton, |
2b9bd5dcf8d2
Adding support for using keyboard to edit cfile interface variables displayed in Grid
laurent
parents:
610
diff
changeset
|
585 |
"Delete": self.DeleteVariableButton, |
2b9bd5dcf8d2
Adding support for using keyboard to edit cfile interface variables displayed in Grid
laurent
parents:
610
diff
changeset
|
586 |
"Up": self.UpVariableButton, |
2b9bd5dcf8d2
Adding support for using keyboard to edit cfile interface variables displayed in Grid
laurent
parents:
610
diff
changeset
|
587 |
"Down": self.DownVariableButton}) |
2b9bd5dcf8d2
Adding support for using keyboard to edit cfile interface variables displayed in Grid
laurent
parents:
610
diff
changeset
|
588 |
|
2b9bd5dcf8d2
Adding support for using keyboard to edit cfile interface variables displayed in Grid
laurent
parents:
610
diff
changeset
|
589 |
def _AddVariable(new_row): |
2b9bd5dcf8d2
Adding support for using keyboard to edit cfile interface variables displayed in Grid
laurent
parents:
610
diff
changeset
|
590 |
self.Table.InsertRow(new_row, self.VariablesDefaultValue.copy()) |
2b9bd5dcf8d2
Adding support for using keyboard to edit cfile interface variables displayed in Grid
laurent
parents:
610
diff
changeset
|
591 |
self.RefreshModel() |
2b9bd5dcf8d2
Adding support for using keyboard to edit cfile interface variables displayed in Grid
laurent
parents:
610
diff
changeset
|
592 |
self.RefreshView() |
2b9bd5dcf8d2
Adding support for using keyboard to edit cfile interface variables displayed in Grid
laurent
parents:
610
diff
changeset
|
593 |
return new_row |
2b9bd5dcf8d2
Adding support for using keyboard to edit cfile interface variables displayed in Grid
laurent
parents:
610
diff
changeset
|
594 |
setattr(self.VariablesGrid, "_AddRow", _AddVariable) |
2b9bd5dcf8d2
Adding support for using keyboard to edit cfile interface variables displayed in Grid
laurent
parents:
610
diff
changeset
|
595 |
|
2b9bd5dcf8d2
Adding support for using keyboard to edit cfile interface variables displayed in Grid
laurent
parents:
610
diff
changeset
|
596 |
def _DeleteVariable(row): |
2b9bd5dcf8d2
Adding support for using keyboard to edit cfile interface variables displayed in Grid
laurent
parents:
610
diff
changeset
|
597 |
self.Table.RemoveRow(row) |
2b9bd5dcf8d2
Adding support for using keyboard to edit cfile interface variables displayed in Grid
laurent
parents:
610
diff
changeset
|
598 |
self.RefreshModel() |
2b9bd5dcf8d2
Adding support for using keyboard to edit cfile interface variables displayed in Grid
laurent
parents:
610
diff
changeset
|
599 |
self.RefreshView() |
2b9bd5dcf8d2
Adding support for using keyboard to edit cfile interface variables displayed in Grid
laurent
parents:
610
diff
changeset
|
600 |
setattr(self.VariablesGrid, "_DeleteRow", _DeleteVariable) |
2b9bd5dcf8d2
Adding support for using keyboard to edit cfile interface variables displayed in Grid
laurent
parents:
610
diff
changeset
|
601 |
|
2b9bd5dcf8d2
Adding support for using keyboard to edit cfile interface variables displayed in Grid
laurent
parents:
610
diff
changeset
|
602 |
def _MoveVariable(row, move): |
2b9bd5dcf8d2
Adding support for using keyboard to edit cfile interface variables displayed in Grid
laurent
parents:
610
diff
changeset
|
603 |
new_row = self.Table.MoveRow(row, move) |
2b9bd5dcf8d2
Adding support for using keyboard to edit cfile interface variables displayed in Grid
laurent
parents:
610
diff
changeset
|
604 |
if new_row != row: |
2b9bd5dcf8d2
Adding support for using keyboard to edit cfile interface variables displayed in Grid
laurent
parents:
610
diff
changeset
|
605 |
self.RefreshModel() |
2b9bd5dcf8d2
Adding support for using keyboard to edit cfile interface variables displayed in Grid
laurent
parents:
610
diff
changeset
|
606 |
self.RefreshView() |
2b9bd5dcf8d2
Adding support for using keyboard to edit cfile interface variables displayed in Grid
laurent
parents:
610
diff
changeset
|
607 |
return new_row |
2b9bd5dcf8d2
Adding support for using keyboard to edit cfile interface variables displayed in Grid
laurent
parents:
610
diff
changeset
|
608 |
setattr(self.VariablesGrid, "_MoveRow", _MoveVariable) |
2b9bd5dcf8d2
Adding support for using keyboard to edit cfile interface variables displayed in Grid
laurent
parents:
610
diff
changeset
|
609 |
|
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
|
610 |
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
|
611 |
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
|
612 |
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
|
613 |
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
|
614 |
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
|
615 |
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
|
616 |
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
|
617 |
|
94855f7b08a9
Improving c_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 |
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
|
619 |
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
|
620 |
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
|
621 |
|
94855f7b08a9
Improving c_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 |
# 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
|
623 |
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
|
624 |
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
|
625 |
self.ParentWindow.RefreshTitle() |
587 | 626 |
self.ParentWindow.RefreshFileMenu() |
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
|
627 |
self.ParentWindow.RefreshEditMenu() |
630
91b2ae63ea3d
Including external tools for editing plugin informations into Beremiz window
laurent
parents:
626
diff
changeset
|
628 |
self.ParentWindow.RefreshPageTitles() |
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
|
629 |
|
94855f7b08a9
Improving c_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 |
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
|
631 |
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
|
632 |
self.Table.ResetView(self.VariablesGrid) |
626
2b9bd5dcf8d2
Adding support for using keyboard to edit cfile interface variables displayed in Grid
laurent
parents:
610
diff
changeset
|
633 |
self.VariablesGrid.RefreshButtons() |
2b9bd5dcf8d2
Adding support for using keyboard to edit cfile interface variables displayed in Grid
laurent
parents:
610
diff
changeset
|
634 |
|
630
91b2ae63ea3d
Including external tools for editing plugin informations into Beremiz window
laurent
parents:
626
diff
changeset
|
635 |
def DoGetBestSize(self): |
91b2ae63ea3d
Including external tools for editing plugin informations into Beremiz window
laurent
parents:
626
diff
changeset
|
636 |
return self.ParentWindow.GetPanelBestSize() |
91b2ae63ea3d
Including external tools for editing plugin informations into Beremiz window
laurent
parents:
626
diff
changeset
|
637 |
|
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
|
638 |
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
|
639 |
self.RefreshModel() |
656
c1792dfc8c7e
Fixing bug integrated plugin editors not closed when removing corresponding plugin
laurent
parents:
653
diff
changeset
|
640 |
wx.CallAfter(self.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
|
641 |
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
|
642 |
|
94855f7b08a9
Improving c_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 |
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
|
644 |
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
|
645 |
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
|
646 |
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
|
647 |
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
|
648 |
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
|
649 |
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
|
650 |
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
|
651 |
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
|
652 |
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
|
653 |
datatype_menu = wx.Menu(title='') |
610
00df5b1db283
Disabling definition of enumerated and structure variables for interfacing with PLC in c_ext plug-in
laurent
parents:
603
diff
changeset
|
654 |
for datatype in self.Controler.GetDataTypes(basetypes=False, only_locatables=True): |
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
|
655 |
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
|
656 |
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
|
657 |
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
|
658 |
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
|
659 |
rect = self.VariablesGrid.BlockToDeviceRect((row, col), (row, col)) |
708 | 660 |
|
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
|
661 |
self.VariablesGrid.PopupMenuXY(type_menu, rect.x + rect.width, rect.y + self.VariablesGrid.GetColLabelSize()) |
708 | 662 |
type_menu.Destroy() |
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
|
663 |
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
|
664 |
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
|
665 |
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
|
666 |
|
94855f7b08a9
Improving c_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 |
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
|
668 |
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
|
669 |
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
|
670 |
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
|
671 |
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
|
672 |
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
|
673 |
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
|
674 |
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
|
675 |
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
|
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 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
|
678 |
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
|
679 |
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
|
680 |
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
|
681 |
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
|
682 |
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
|
683 |
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
|
684 |
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
|
685 |
num += 1 |
603
e1ef99c609eb
added memory location support to C file pluguin
Edouard Tisserant
parents:
587
diff
changeset
|
686 |
elif self.Table.GetValueByName(row, "Class") == "memory": |
e1ef99c609eb
added memory location support to C file pluguin
Edouard Tisserant
parents:
587
diff
changeset
|
687 |
dir = "%M" |
e1ef99c609eb
added memory location support to C file pluguin
Edouard Tisserant
parents:
587
diff
changeset
|
688 |
for i in xrange(row): |
e1ef99c609eb
added memory location support to C file pluguin
Edouard Tisserant
parents:
587
diff
changeset
|
689 |
if self.Table.GetValueByName(i, "Class") == "memory": |
e1ef99c609eb
added memory location support to C file pluguin
Edouard Tisserant
parents:
587
diff
changeset
|
690 |
num += 1 |
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
|
691 |
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
|
692 |
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
|
693 |
for i in xrange(row): |
161 | 694 |
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
|
695 |
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
|
696 |
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
|
697 |
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
|
698 |
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
|
699 |
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
|
700 |
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
|
701 |
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
|
702 |
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
|
703 |
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
|
704 |
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
|
705 |
|
94855f7b08a9
Improving c_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 |
|
94855f7b08a9
Improving c_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 |
#------------------------------------------------------------------------------- |
94855f7b08a9
Improving c_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 |
# 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
|
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 |
|
630
91b2ae63ea3d
Including external tools for editing plugin informations into Beremiz window
laurent
parents:
626
diff
changeset
|
711 |
CFILE_PARTS = [ |
91b2ae63ea3d
Including external tools for editing plugin informations into Beremiz window
laurent
parents:
626
diff
changeset
|
712 |
("Includes", CppEditor), |
91b2ae63ea3d
Including external tools for editing plugin informations into Beremiz window
laurent
parents:
626
diff
changeset
|
713 |
("Variables", VariablesEditor), |
91b2ae63ea3d
Including external tools for editing plugin informations into Beremiz window
laurent
parents:
626
diff
changeset
|
714 |
("Globals", CppEditor), |
91b2ae63ea3d
Including external tools for editing plugin informations into Beremiz window
laurent
parents:
626
diff
changeset
|
715 |
("Init", CppEditor), |
91b2ae63ea3d
Including external tools for editing plugin informations into Beremiz window
laurent
parents:
626
diff
changeset
|
716 |
("CleanUp", CppEditor), |
91b2ae63ea3d
Including external tools for editing plugin informations into Beremiz window
laurent
parents:
626
diff
changeset
|
717 |
("Retrieve", CppEditor), |
91b2ae63ea3d
Including external tools for editing plugin informations into Beremiz window
laurent
parents:
626
diff
changeset
|
718 |
("Publish", CppEditor), |
91b2ae63ea3d
Including external tools for editing plugin informations into Beremiz window
laurent
parents:
626
diff
changeset
|
719 |
] |
91b2ae63ea3d
Including external tools for editing plugin informations into Beremiz window
laurent
parents:
626
diff
changeset
|
720 |
|
91b2ae63ea3d
Including external tools for editing plugin informations into Beremiz window
laurent
parents:
626
diff
changeset
|
721 |
#---------------------------------------------------------------------- |
91b2ae63ea3d
Including external tools for editing plugin informations into Beremiz window
laurent
parents:
626
diff
changeset
|
722 |
# different icons for the collapsed/expanded states. |
91b2ae63ea3d
Including external tools for editing plugin informations into Beremiz window
laurent
parents:
626
diff
changeset
|
723 |
# Taken from standard Windows XP collapsed/expanded states. |
91b2ae63ea3d
Including external tools for editing plugin informations into Beremiz window
laurent
parents:
626
diff
changeset
|
724 |
#---------------------------------------------------------------------- |
91b2ae63ea3d
Including external tools for editing plugin informations into Beremiz window
laurent
parents:
626
diff
changeset
|
725 |
|
91b2ae63ea3d
Including external tools for editing plugin informations into Beremiz window
laurent
parents:
626
diff
changeset
|
726 |
def GetCollapsedIconData(): |
91b2ae63ea3d
Including external tools for editing plugin informations into Beremiz window
laurent
parents:
626
diff
changeset
|
727 |
return \ |
91b2ae63ea3d
Including external tools for editing plugin informations into Beremiz window
laurent
parents:
626
diff
changeset
|
728 |
'\x89PNG\r\n\x1a\n\x00\x00\x00\rIHDR\x00\x00\x00\x10\x00\x00\x00\x10\x08\x06\ |
91b2ae63ea3d
Including external tools for editing plugin informations into Beremiz window
laurent
parents:
626
diff
changeset
|
729 |
\x00\x00\x00\x1f\xf3\xffa\x00\x00\x00\x04sBIT\x08\x08\x08\x08|\x08d\x88\x00\ |
91b2ae63ea3d
Including external tools for editing plugin informations into Beremiz window
laurent
parents:
626
diff
changeset
|
730 |
\x00\x01\x8eIDAT8\x8d\xa5\x93-n\xe4@\x10\x85?g\x03\n6lh)\xc4\xd2\x12\xc3\x81\ |
91b2ae63ea3d
Including external tools for editing plugin informations into Beremiz window
laurent
parents:
626
diff
changeset
|
731 |
\xd6\xa2I\x90\x154\xb9\x81\x8f1G\xc8\x11\x16\x86\xcd\xa0\x99F\xb3A\x91\xa1\ |
91b2ae63ea3d
Including external tools for editing plugin informations into Beremiz window
laurent
parents:
626
diff
changeset
|
732 |
\xc9J&\x96L"5lX\xcc\x0bl\xf7v\xb2\x7fZ\xa5\x98\xebU\xbdz\xf5\\\x9deW\x9f\xf8\ |
91b2ae63ea3d
Including external tools for editing plugin informations into Beremiz window
laurent
parents:
626
diff
changeset
|
733 |
H\\\xbfO|{y\x9dT\x15P\x04\x01\x01UPUD\x84\xdb/7YZ\x9f\xa5\n\xce\x97aRU\x8a\ |
91b2ae63ea3d
Including external tools for editing plugin informations into Beremiz window
laurent
parents:
626
diff
changeset
|
734 |
\xdc`\xacA\x00\x04P\xf0!0\xf6\x81\xa0\xf0p\xff9\xfb\x85\xe0|\x19&T)K\x8b\x18\ |
91b2ae63ea3d
Including external tools for editing plugin informations into Beremiz window
laurent
parents:
626
diff
changeset
|
735 |
\xf9\xa3\xe4\xbe\xf3\x8c^#\xc9\xd5\n\xa8*\xc5?\x9a\x01\x8a\xd2b\r\x1cN\xc3\ |
91b2ae63ea3d
Including external tools for editing plugin informations into Beremiz window
laurent
parents:
626
diff
changeset
|
736 |
\x14\t\xce\x97a\xb2F0Ks\xd58\xaa\xc6\xc5\xa6\xf7\xdfya\xe7\xbdR\x13M2\xf9\ |
91b2ae63ea3d
Including external tools for editing plugin informations into Beremiz window
laurent
parents:
626
diff
changeset
|
737 |
\xf9qKQ\x1fi\xf6-\x00~T\xfac\x1dq#\x82,\xe5q\x05\x91D\xba@\xefj\xba1\xf0\xdc\ |
91b2ae63ea3d
Including external tools for editing plugin informations into Beremiz window
laurent
parents:
626
diff
changeset
|
738 |
zzW\xcff&\xb8,\x89\xa8@Q\xd6\xaaf\xdfRm,\xee\xb1BDxr#\xae\xf5|\xddo\xd6\xe2H\ |
91b2ae63ea3d
Including external tools for editing plugin informations into Beremiz window
laurent
parents:
626
diff
changeset
|
739 |
\x18\x15\x84\xa0q@]\xe54\x8d\xa3\xedf\x05M\xe3\xd8Uy\xc4\x15\x8d\xf5\xd7\x8b\ |
91b2ae63ea3d
Including external tools for editing plugin informations into Beremiz window
laurent
parents:
626
diff
changeset
|
740 |
~\x82\x0fh\x0e"\xb0\xad,\xee\xb8c\xbb\x18\xe7\x8e;6\xa5\x89\x04\xde\xff\x1c\ |
91b2ae63ea3d
Including external tools for editing plugin informations into Beremiz window
laurent
parents:
626
diff
changeset
|
741 |
\x16\xef\xe0p\xfa>\x19\x11\xca\x8d\x8d\xe0\x93\x1b\x01\xd8m\xf3(;x\xa5\xef=\ |
91b2ae63ea3d
Including external tools for editing plugin informations into Beremiz window
laurent
parents:
626
diff
changeset
|
742 |
\xb7w\xf3\x1d$\x7f\xc1\xe0\xbd\xa7\xeb\xa0(,"Kc\x12\xc1+\xfd\xe8\tI\xee\xed)\ |
91b2ae63ea3d
Including external tools for editing plugin informations into Beremiz window
laurent
parents:
626
diff
changeset
|
743 |
\xbf\xbcN\xc1{D\x04k\x05#\x12\xfd\xf2a\xde[\x81\x87\xbb\xdf\x9cr\x1a\x87\xd3\ |
91b2ae63ea3d
Including external tools for editing plugin informations into Beremiz window
laurent
parents:
626
diff
changeset
|
744 |
0)\xba>\x83\xd5\xb97o\xe0\xaf\x04\xff\x13?\x00\xd2\xfb\xa9`z\xac\x80w\x00\ |
91b2ae63ea3d
Including external tools for editing plugin informations into Beremiz window
laurent
parents:
626
diff
changeset
|
745 |
\x00\x00\x00IEND\xaeB`\x82' |
91b2ae63ea3d
Including external tools for editing plugin informations into Beremiz window
laurent
parents:
626
diff
changeset
|
746 |
|
91b2ae63ea3d
Including external tools for editing plugin informations into Beremiz window
laurent
parents:
626
diff
changeset
|
747 |
def GetCollapsedIconBitmap(): |
91b2ae63ea3d
Including external tools for editing plugin informations into Beremiz window
laurent
parents:
626
diff
changeset
|
748 |
return wx.BitmapFromImage(GetCollapsedIconImage()) |
91b2ae63ea3d
Including external tools for editing plugin informations into Beremiz window
laurent
parents:
626
diff
changeset
|
749 |
|
91b2ae63ea3d
Including external tools for editing plugin informations into Beremiz window
laurent
parents:
626
diff
changeset
|
750 |
def GetCollapsedIconImage(): |
91b2ae63ea3d
Including external tools for editing plugin informations into Beremiz window
laurent
parents:
626
diff
changeset
|
751 |
import cStringIO |
91b2ae63ea3d
Including external tools for editing plugin informations into Beremiz window
laurent
parents:
626
diff
changeset
|
752 |
stream = cStringIO.StringIO(GetCollapsedIconData()) |
91b2ae63ea3d
Including external tools for editing plugin informations into Beremiz window
laurent
parents:
626
diff
changeset
|
753 |
return wx.ImageFromStream(stream) |
91b2ae63ea3d
Including external tools for editing plugin informations into Beremiz window
laurent
parents:
626
diff
changeset
|
754 |
|
91b2ae63ea3d
Including external tools for editing plugin informations into Beremiz window
laurent
parents:
626
diff
changeset
|
755 |
#---------------------------------------------------------------------- |
91b2ae63ea3d
Including external tools for editing plugin informations into Beremiz window
laurent
parents:
626
diff
changeset
|
756 |
def GetExpandedIconData(): |
91b2ae63ea3d
Including external tools for editing plugin informations into Beremiz window
laurent
parents:
626
diff
changeset
|
757 |
return \ |
91b2ae63ea3d
Including external tools for editing plugin informations into Beremiz window
laurent
parents:
626
diff
changeset
|
758 |
'\x89PNG\r\n\x1a\n\x00\x00\x00\rIHDR\x00\x00\x00\x10\x00\x00\x00\x10\x08\x06\ |
91b2ae63ea3d
Including external tools for editing plugin informations into Beremiz window
laurent
parents:
626
diff
changeset
|
759 |
\x00\x00\x00\x1f\xf3\xffa\x00\x00\x00\x04sBIT\x08\x08\x08\x08|\x08d\x88\x00\ |
91b2ae63ea3d
Including external tools for editing plugin informations into Beremiz window
laurent
parents:
626
diff
changeset
|
760 |
\x00\x01\x9fIDAT8\x8d\x95\x93\xa1\x8e\xdc0\x14EO\xb2\xc4\xd0\xd2\x12\xb7(mI\ |
91b2ae63ea3d
Including external tools for editing plugin informations into Beremiz window
laurent
parents:
626
diff
changeset
|
761 |
\xa4%V\xd1lQT4[4-\x9a\xfe\xc1\xc2|\xc6\xc2~BY\x83:A3E\xd3\xa0*\xa4\xd2\x90H!\ |
91b2ae63ea3d
Including external tools for editing plugin informations into Beremiz window
laurent
parents:
626
diff
changeset
|
762 |
\x95\x0c\r\r\x1fK\x81g\xb2\x99\x84\xb4\x0fY\xd6\xbb\xc7\xf7>=\'Iz\xc3\xbcv\ |
91b2ae63ea3d
Including external tools for editing plugin informations into Beremiz window
laurent
parents:
626
diff
changeset
|
763 |
\xfbn\xb8\x9c\x15 \xe7\xf3\xc7\x0fw\xc9\xbc7\x99\x03\x0e\xfbn0\x99F+\x85R\ |
91b2ae63ea3d
Including external tools for editing plugin informations into Beremiz window
laurent
parents:
626
diff
changeset
|
764 |
\x80RH\x10\x82\x08\xde\x05\x1ef\x90+\xc0\xe1\xd8\ryn\xd0Z-\\A\xb4\xd2\xf7\ |
91b2ae63ea3d
Including external tools for editing plugin informations into Beremiz window
laurent
parents:
626
diff
changeset
|
765 |
\x9e\xfbwoF\xc8\x088\x1c\xbbae\xb3\xe8y&\x9a\xdf\xf5\xbd\xe7\xfem\x84\xa4\ |
91b2ae63ea3d
Including external tools for editing plugin informations into Beremiz window
laurent
parents:
626
diff
changeset
|
766 |
\x97\xccYf\x16\x8d\xdb\xb2a]\xfeX\x18\xc9s\xc3\xe1\x18\xe7\x94\x12cb\xcc\xb5\ |
91b2ae63ea3d
Including external tools for editing plugin informations into Beremiz window
laurent
parents:
626
diff
changeset
|
767 |
\xfa\xb1l8\xf5\x01\xe7\x84\xc7\xb2Y@\xb2\xcc0\x02\xb4\x9a\x88%\xbe\xdc\xb4\ |
91b2ae63ea3d
Including external tools for editing plugin informations into Beremiz window
laurent
parents:
626
diff
changeset
|
768 |
\x9e\xb6Zs\xaa74\xadg[6\x88<\xb7]\xc6\x14\x1dL\x86\xe6\x83\xa0\x81\xba\xda\ |
91b2ae63ea3d
Including external tools for editing plugin informations into Beremiz window
laurent
parents:
626
diff
changeset
|
769 |
\x10\x02x/\xd4\xd5\x06\r\x840!\x9c\x1fM\x92\xf4\x86\x9f\xbf\xfe\x0c\xd6\x9ae\ |
91b2ae63ea3d
Including external tools for editing plugin informations into Beremiz window
laurent
parents:
626
diff
changeset
|
770 |
\xd6u\x8d \xf4\xf5\x165\x9b\x8f\x04\xe1\xc5\xcb\xdb$\x05\x90\xa97@\x04lQas\ |
91b2ae63ea3d
Including external tools for editing plugin informations into Beremiz window
laurent
parents:
626
diff
changeset
|
771 |
\xcd*7\x14\xdb\x9aY\xcb\xb8\\\xe9E\x10|\xbc\xf2^\xb0E\x85\xc95_\x9f\n\xaa/\ |
91b2ae63ea3d
Including external tools for editing plugin informations into Beremiz window
laurent
parents:
626
diff
changeset
|
772 |
\x05\x10\x81\xce\xc9\xa8\xf6><G\xd8\xed\xbbA)X\xd9\x0c\x01\x9a\xc6Q\x14\xd9h\ |
91b2ae63ea3d
Including external tools for editing plugin informations into Beremiz window
laurent
parents:
626
diff
changeset
|
773 |
[\x04\xda\xd6c\xadFkE\xf0\xc2\xab\xd7\xb7\xc9\x08\x00\xf8\xf6\xbd\x1b\x8cQ\ |
91b2ae63ea3d
Including external tools for editing plugin informations into Beremiz window
laurent
parents:
626
diff
changeset
|
774 |
\xd8|\xb9\x0f\xd3\x9a\x8a\xc7\x08\x00\x9f?\xdd%\xde\x07\xda\x93\xc3{\x19C\ |
91b2ae63ea3d
Including external tools for editing plugin informations into Beremiz window
laurent
parents:
626
diff
changeset
|
775 |
\x8a\x9c\x03\x0b8\x17\xe8\x9d\xbf\x02.>\x13\xc0n\xff{PJ\xc5\xfdP\x11""<\xbc\ |
91b2ae63ea3d
Including external tools for editing plugin informations into Beremiz window
laurent
parents:
626
diff
changeset
|
776 |
\xff\x87\xdf\xf8\xbf\xf5\x17FF\xaf\x8f\x8b\xd3\xe6K\x00\x00\x00\x00IEND\xaeB\ |
91b2ae63ea3d
Including external tools for editing plugin informations into Beremiz window
laurent
parents:
626
diff
changeset
|
777 |
`\x82' |
91b2ae63ea3d
Including external tools for editing plugin informations into Beremiz window
laurent
parents:
626
diff
changeset
|
778 |
|
91b2ae63ea3d
Including external tools for editing plugin informations into Beremiz window
laurent
parents:
626
diff
changeset
|
779 |
def GetExpandedIconBitmap(): |
91b2ae63ea3d
Including external tools for editing plugin informations into Beremiz window
laurent
parents:
626
diff
changeset
|
780 |
return wx.BitmapFromImage(GetExpandedIconImage()) |
91b2ae63ea3d
Including external tools for editing plugin informations into Beremiz window
laurent
parents:
626
diff
changeset
|
781 |
|
91b2ae63ea3d
Including external tools for editing plugin informations into Beremiz window
laurent
parents:
626
diff
changeset
|
782 |
def GetExpandedIconImage(): |
91b2ae63ea3d
Including external tools for editing plugin informations into Beremiz window
laurent
parents:
626
diff
changeset
|
783 |
import cStringIO |
91b2ae63ea3d
Including external tools for editing plugin informations into Beremiz window
laurent
parents:
626
diff
changeset
|
784 |
stream = cStringIO.StringIO(GetExpandedIconData()) |
91b2ae63ea3d
Including external tools for editing plugin informations into Beremiz window
laurent
parents:
626
diff
changeset
|
785 |
return wx.ImageFromStream(stream) |
91b2ae63ea3d
Including external tools for editing plugin informations into Beremiz window
laurent
parents:
626
diff
changeset
|
786 |
|
91b2ae63ea3d
Including external tools for editing plugin informations into Beremiz window
laurent
parents:
626
diff
changeset
|
787 |
class FoldPanelCaption(wx.lib.buttons.GenBitmapTextToggleButton): |
91b2ae63ea3d
Including external tools for editing plugin informations into Beremiz window
laurent
parents:
626
diff
changeset
|
788 |
|
91b2ae63ea3d
Including external tools for editing plugin informations into Beremiz window
laurent
parents:
626
diff
changeset
|
789 |
def GetBackgroundBrush(self, dc): |
91b2ae63ea3d
Including external tools for editing plugin informations into Beremiz window
laurent
parents:
626
diff
changeset
|
790 |
colBg = self.GetBackgroundColour() |
91b2ae63ea3d
Including external tools for editing plugin informations into Beremiz window
laurent
parents:
626
diff
changeset
|
791 |
brush = wx.Brush(colBg, wx.SOLID) |
91b2ae63ea3d
Including external tools for editing plugin informations into Beremiz window
laurent
parents:
626
diff
changeset
|
792 |
if self.style & wx.BORDER_NONE: |
91b2ae63ea3d
Including external tools for editing plugin informations into Beremiz window
laurent
parents:
626
diff
changeset
|
793 |
myAttr = self.GetDefaultAttributes() |
91b2ae63ea3d
Including external tools for editing plugin informations into Beremiz window
laurent
parents:
626
diff
changeset
|
794 |
parAttr = self.GetParent().GetDefaultAttributes() |
91b2ae63ea3d
Including external tools for editing plugin informations into Beremiz window
laurent
parents:
626
diff
changeset
|
795 |
myDef = colBg == myAttr.colBg |
91b2ae63ea3d
Including external tools for editing plugin informations into Beremiz window
laurent
parents:
626
diff
changeset
|
796 |
parDef = self.GetParent().GetBackgroundColour() == parAttr.colBg |
91b2ae63ea3d
Including external tools for editing plugin informations into Beremiz window
laurent
parents:
626
diff
changeset
|
797 |
if myDef and parDef: |
91b2ae63ea3d
Including external tools for editing plugin informations into Beremiz window
laurent
parents:
626
diff
changeset
|
798 |
if wx.Platform == "__WXMAC__": |
91b2ae63ea3d
Including external tools for editing plugin informations into Beremiz window
laurent
parents:
626
diff
changeset
|
799 |
brush.MacSetTheme(1) # 1 == kThemeBrushDialogBackgroundActive |
91b2ae63ea3d
Including external tools for editing plugin informations into Beremiz window
laurent
parents:
626
diff
changeset
|
800 |
elif wx.Platform == "__WXMSW__": |
91b2ae63ea3d
Including external tools for editing plugin informations into Beremiz window
laurent
parents:
626
diff
changeset
|
801 |
if self.DoEraseBackground(dc): |
91b2ae63ea3d
Including external tools for editing plugin informations into Beremiz window
laurent
parents:
626
diff
changeset
|
802 |
brush = None |
91b2ae63ea3d
Including external tools for editing plugin informations into Beremiz window
laurent
parents:
626
diff
changeset
|
803 |
elif myDef and not parDef: |
91b2ae63ea3d
Including external tools for editing plugin informations into Beremiz window
laurent
parents:
626
diff
changeset
|
804 |
colBg = self.GetParent().GetBackgroundColour() |
91b2ae63ea3d
Including external tools for editing plugin informations into Beremiz window
laurent
parents:
626
diff
changeset
|
805 |
brush = wx.Brush(colBg, wx.SOLID) |
91b2ae63ea3d
Including external tools for editing plugin informations into Beremiz window
laurent
parents:
626
diff
changeset
|
806 |
return brush |
91b2ae63ea3d
Including external tools for editing plugin informations into Beremiz window
laurent
parents:
626
diff
changeset
|
807 |
|
91b2ae63ea3d
Including external tools for editing plugin informations into Beremiz window
laurent
parents:
626
diff
changeset
|
808 |
def DrawLabel(self, dc, width, height, dx=0, dy=0): |
91b2ae63ea3d
Including external tools for editing plugin informations into Beremiz window
laurent
parents:
626
diff
changeset
|
809 |
bmp = self.bmpLabel |
91b2ae63ea3d
Including external tools for editing plugin informations into Beremiz window
laurent
parents:
626
diff
changeset
|
810 |
if bmp is not None: # if the bitmap is used |
91b2ae63ea3d
Including external tools for editing plugin informations into Beremiz window
laurent
parents:
626
diff
changeset
|
811 |
if self.bmpDisabled and not self.IsEnabled(): |
91b2ae63ea3d
Including external tools for editing plugin informations into Beremiz window
laurent
parents:
626
diff
changeset
|
812 |
bmp = self.bmpDisabled |
91b2ae63ea3d
Including external tools for editing plugin informations into Beremiz window
laurent
parents:
626
diff
changeset
|
813 |
if self.bmpFocus and self.hasFocus: |
91b2ae63ea3d
Including external tools for editing plugin informations into Beremiz window
laurent
parents:
626
diff
changeset
|
814 |
bmp = self.bmpFocus |
91b2ae63ea3d
Including external tools for editing plugin informations into Beremiz window
laurent
parents:
626
diff
changeset
|
815 |
if self.bmpSelected and not self.up: |
91b2ae63ea3d
Including external tools for editing plugin informations into Beremiz window
laurent
parents:
626
diff
changeset
|
816 |
bmp = self.bmpSelected |
91b2ae63ea3d
Including external tools for editing plugin informations into Beremiz window
laurent
parents:
626
diff
changeset
|
817 |
bw,bh = bmp.GetWidth(), bmp.GetHeight() |
91b2ae63ea3d
Including external tools for editing plugin informations into Beremiz window
laurent
parents:
626
diff
changeset
|
818 |
hasMask = bmp.GetMask() is not None |
91b2ae63ea3d
Including external tools for editing plugin informations into Beremiz window
laurent
parents:
626
diff
changeset
|
819 |
else: |
91b2ae63ea3d
Including external tools for editing plugin informations into Beremiz window
laurent
parents:
626
diff
changeset
|
820 |
bw = bh = 0 # no bitmap -> size is zero |
91b2ae63ea3d
Including external tools for editing plugin informations into Beremiz window
laurent
parents:
626
diff
changeset
|
821 |
|
91b2ae63ea3d
Including external tools for editing plugin informations into Beremiz window
laurent
parents:
626
diff
changeset
|
822 |
dc.SetFont(self.GetFont()) |
91b2ae63ea3d
Including external tools for editing plugin informations into Beremiz window
laurent
parents:
626
diff
changeset
|
823 |
if self.IsEnabled(): |
91b2ae63ea3d
Including external tools for editing plugin informations into Beremiz window
laurent
parents:
626
diff
changeset
|
824 |
dc.SetTextForeground(self.GetForegroundColour()) |
91b2ae63ea3d
Including external tools for editing plugin informations into Beremiz window
laurent
parents:
626
diff
changeset
|
825 |
else: |
91b2ae63ea3d
Including external tools for editing plugin informations into Beremiz window
laurent
parents:
626
diff
changeset
|
826 |
dc.SetTextForeground(wx.SystemSettings.GetColour(wx.SYS_COLOUR_GRAYTEXT)) |
91b2ae63ea3d
Including external tools for editing plugin informations into Beremiz window
laurent
parents:
626
diff
changeset
|
827 |
|
91b2ae63ea3d
Including external tools for editing plugin informations into Beremiz window
laurent
parents:
626
diff
changeset
|
828 |
label = self.GetLabel() |
91b2ae63ea3d
Including external tools for editing plugin informations into Beremiz window
laurent
parents:
626
diff
changeset
|
829 |
tw, th = dc.GetTextExtent(label) # size of text |
91b2ae63ea3d
Including external tools for editing plugin informations into Beremiz window
laurent
parents:
626
diff
changeset
|
830 |
|
91b2ae63ea3d
Including external tools for editing plugin informations into Beremiz window
laurent
parents:
626
diff
changeset
|
831 |
if bmp is not None: |
91b2ae63ea3d
Including external tools for editing plugin informations into Beremiz window
laurent
parents:
626
diff
changeset
|
832 |
dc.DrawBitmap(bmp, width - bw - 2, (height-bh)/2, hasMask) # draw bitmap if available |
91b2ae63ea3d
Including external tools for editing plugin informations into Beremiz window
laurent
parents:
626
diff
changeset
|
833 |
|
91b2ae63ea3d
Including external tools for editing plugin informations into Beremiz window
laurent
parents:
626
diff
changeset
|
834 |
dc.DrawText(label, 2, (height-th)/2) # draw the text |
91b2ae63ea3d
Including external tools for editing plugin informations into Beremiz window
laurent
parents:
626
diff
changeset
|
835 |
|
91b2ae63ea3d
Including external tools for editing plugin informations into Beremiz window
laurent
parents:
626
diff
changeset
|
836 |
dc.SetPen(wx.Pen(self.GetForegroundColour())) |
91b2ae63ea3d
Including external tools for editing plugin informations into Beremiz window
laurent
parents:
626
diff
changeset
|
837 |
dc.SetBrush(wx.TRANSPARENT_BRUSH) |
91b2ae63ea3d
Including external tools for editing plugin informations into Beremiz window
laurent
parents:
626
diff
changeset
|
838 |
dc.DrawRectangle(0, 0, width, height) |
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
|
839 |
|
94855f7b08a9
Improving c_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 |
[ID_CFILEEDITOR, ID_CFILEEDITORMAINSPLITTER, |
164 | 841 |
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
|
842 |
] = [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
|
843 |
|
630
91b2ae63ea3d
Including external tools for editing plugin informations into Beremiz window
laurent
parents:
626
diff
changeset
|
844 |
class CFileEditor(EditorPanel): |
91b2ae63ea3d
Including external tools for editing plugin informations into Beremiz window
laurent
parents:
626
diff
changeset
|
845 |
|
91b2ae63ea3d
Including external tools for editing plugin informations into Beremiz window
laurent
parents:
626
diff
changeset
|
846 |
def _init_Editor(self, prnt): |
658 | 847 |
self.Editor = wx.Panel(id=ID_CFILEEDITOR, parent=prnt, pos=wx.Point(0, 0), |
630
91b2ae63ea3d
Including external tools for editing plugin informations into Beremiz window
laurent
parents:
626
diff
changeset
|
848 |
size=wx.Size(0, 0), style=wx.TAB_TRAVERSAL) |
91b2ae63ea3d
Including external tools for editing plugin informations into Beremiz window
laurent
parents:
626
diff
changeset
|
849 |
|
91b2ae63ea3d
Including external tools for editing plugin informations into Beremiz window
laurent
parents:
626
diff
changeset
|
850 |
self.Panels = {} |
91b2ae63ea3d
Including external tools for editing plugin informations into Beremiz window
laurent
parents:
626
diff
changeset
|
851 |
self.MainSizer = wx.FlexGridSizer(cols=1, hgap=0, rows=2 * len(CFILE_PARTS) + 1, vgap=0) |
91b2ae63ea3d
Including external tools for editing plugin informations into Beremiz window
laurent
parents:
626
diff
changeset
|
852 |
self.MainSizer.AddGrowableCol(0) |
91b2ae63ea3d
Including external tools for editing plugin informations into Beremiz window
laurent
parents:
626
diff
changeset
|
853 |
|
91b2ae63ea3d
Including external tools for editing plugin informations into Beremiz window
laurent
parents:
626
diff
changeset
|
854 |
for idx, (name, panel_class) in enumerate(CFILE_PARTS): |
91b2ae63ea3d
Including external tools for editing plugin informations into Beremiz window
laurent
parents:
626
diff
changeset
|
855 |
button_id = wx.NewId() |
91b2ae63ea3d
Including external tools for editing plugin informations into Beremiz window
laurent
parents:
626
diff
changeset
|
856 |
button = FoldPanelCaption(id=button_id, name='FoldPanelCaption_%s' % name, |
91b2ae63ea3d
Including external tools for editing plugin informations into Beremiz window
laurent
parents:
626
diff
changeset
|
857 |
label=name, bitmap=GetCollapsedIconBitmap(), parent=self.Editor, pos=wx.Point(0, 0), |
91b2ae63ea3d
Including external tools for editing plugin informations into Beremiz window
laurent
parents:
626
diff
changeset
|
858 |
size=wx.Size(0, 20), style=wx.NO_BORDER|wx.ALIGN_LEFT) |
91b2ae63ea3d
Including external tools for editing plugin informations into Beremiz window
laurent
parents:
626
diff
changeset
|
859 |
button.SetBitmapSelected(GetExpandedIconBitmap()) |
91b2ae63ea3d
Including external tools for editing plugin informations into Beremiz window
laurent
parents:
626
diff
changeset
|
860 |
button.Bind(wx.EVT_BUTTON, self.GenPanelButtonCallback(name), id=button_id) |
91b2ae63ea3d
Including external tools for editing plugin informations into Beremiz window
laurent
parents:
626
diff
changeset
|
861 |
self.MainSizer.AddWindow(button, 0, border=0, flag=wx.TOP|wx.GROW) |
91b2ae63ea3d
Including external tools for editing plugin informations into Beremiz window
laurent
parents:
626
diff
changeset
|
862 |
|
91b2ae63ea3d
Including external tools for editing plugin informations into Beremiz window
laurent
parents:
626
diff
changeset
|
863 |
if panel_class == VariablesEditor: |
91b2ae63ea3d
Including external tools for editing plugin informations into Beremiz window
laurent
parents:
626
diff
changeset
|
864 |
panel = VariablesEditor(self.Editor, self.ParentWindow, self.Controler) |
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
|
865 |
else: |
630
91b2ae63ea3d
Including external tools for editing plugin informations into Beremiz window
laurent
parents:
626
diff
changeset
|
866 |
panel = panel_class(self.Editor, name, self.ParentWindow, self.Controler) |
91b2ae63ea3d
Including external tools for editing plugin informations into Beremiz window
laurent
parents:
626
diff
changeset
|
867 |
self.MainSizer.AddWindow(panel, 0, border=0, flag=wx.BOTTOM|wx.GROW) |
91b2ae63ea3d
Including external tools for editing plugin informations into Beremiz window
laurent
parents:
626
diff
changeset
|
868 |
panel.Hide() |
91b2ae63ea3d
Including external tools for editing plugin informations into Beremiz window
laurent
parents:
626
diff
changeset
|
869 |
|
91b2ae63ea3d
Including external tools for editing plugin informations into Beremiz window
laurent
parents:
626
diff
changeset
|
870 |
self.Panels[name] = {"button": button, "panel": panel, "expanded": False, "row": 2 * idx + 1} |
91b2ae63ea3d
Including external tools for editing plugin informations into Beremiz window
laurent
parents:
626
diff
changeset
|
871 |
|
91b2ae63ea3d
Including external tools for editing plugin informations into Beremiz window
laurent
parents:
626
diff
changeset
|
872 |
self.Spacer = wx.Panel(self.Editor, -1) |
91b2ae63ea3d
Including external tools for editing plugin informations into Beremiz window
laurent
parents:
626
diff
changeset
|
873 |
self.SpacerExpanded = True |
91b2ae63ea3d
Including external tools for editing plugin informations into Beremiz window
laurent
parents:
626
diff
changeset
|
874 |
self.MainSizer.AddWindow(self.Spacer, 0, border=0, flag=wx.GROW) |
91b2ae63ea3d
Including external tools for editing plugin informations into Beremiz window
laurent
parents:
626
diff
changeset
|
875 |
|
91b2ae63ea3d
Including external tools for editing plugin informations into Beremiz window
laurent
parents:
626
diff
changeset
|
876 |
self.MainSizer.AddGrowableRow(2 * len(CFILE_PARTS)) |
91b2ae63ea3d
Including external tools for editing plugin informations into Beremiz window
laurent
parents:
626
diff
changeset
|
877 |
|
91b2ae63ea3d
Including external tools for editing plugin informations into Beremiz window
laurent
parents:
626
diff
changeset
|
878 |
self.Editor.SetSizer(self.MainSizer) |
91b2ae63ea3d
Including external tools for editing plugin informations into Beremiz window
laurent
parents:
626
diff
changeset
|
879 |
|
91b2ae63ea3d
Including external tools for editing plugin informations into Beremiz window
laurent
parents:
626
diff
changeset
|
880 |
def __init__(self, parent, controler, window): |
91b2ae63ea3d
Including external tools for editing plugin informations into Beremiz window
laurent
parents:
626
diff
changeset
|
881 |
EditorPanel.__init__(self, parent, "", window, controler) |
91b2ae63ea3d
Including external tools for editing plugin informations into Beremiz window
laurent
parents:
626
diff
changeset
|
882 |
|
91b2ae63ea3d
Including external tools for editing plugin informations into Beremiz window
laurent
parents:
626
diff
changeset
|
883 |
img = wx.Bitmap(self.Controler.GetIconPath("Cfile.png"), wx.BITMAP_TYPE_PNG).ConvertToImage() |
91b2ae63ea3d
Including external tools for editing plugin informations into Beremiz window
laurent
parents:
626
diff
changeset
|
884 |
self.SetIcon(wx.BitmapFromImage(img.Rescale(16, 16))) |
91b2ae63ea3d
Including external tools for editing plugin informations into Beremiz window
laurent
parents:
626
diff
changeset
|
885 |
|
658 | 886 |
def __del__(self): |
675
44b35c27e9ff
Adding support for quickly open recent projects in file menu
laurent
parents:
665
diff
changeset
|
887 |
self.Controler.OnCloseEditor(self) |
658 | 888 |
|
630
91b2ae63ea3d
Including external tools for editing plugin informations into Beremiz window
laurent
parents:
626
diff
changeset
|
889 |
def GetTitle(self): |
718 | 890 |
fullname = self.Controler.CTNFullName() |
630
91b2ae63ea3d
Including external tools for editing plugin informations into Beremiz window
laurent
parents:
626
diff
changeset
|
891 |
if not self.Controler.CFileIsSaved(): |
656
c1792dfc8c7e
Fixing bug integrated plugin editors not closed when removing corresponding plugin
laurent
parents:
653
diff
changeset
|
892 |
return "~%s~" % fullname |
c1792dfc8c7e
Fixing bug integrated plugin editors not closed when removing corresponding plugin
laurent
parents:
653
diff
changeset
|
893 |
return fullname |
630
91b2ae63ea3d
Including external tools for editing plugin informations into Beremiz window
laurent
parents:
626
diff
changeset
|
894 |
|
91b2ae63ea3d
Including external tools for editing plugin informations into Beremiz window
laurent
parents:
626
diff
changeset
|
895 |
def GetBufferState(self): |
91b2ae63ea3d
Including external tools for editing plugin informations into Beremiz window
laurent
parents:
626
diff
changeset
|
896 |
return self.Controler.GetBufferState() |
91b2ae63ea3d
Including external tools for editing plugin informations into Beremiz window
laurent
parents:
626
diff
changeset
|
897 |
|
91b2ae63ea3d
Including external tools for editing plugin informations into Beremiz window
laurent
parents:
626
diff
changeset
|
898 |
def Undo(self): |
91b2ae63ea3d
Including external tools for editing plugin informations into Beremiz window
laurent
parents:
626
diff
changeset
|
899 |
self.Controler.LoadPrevious() |
91b2ae63ea3d
Including external tools for editing plugin informations into Beremiz window
laurent
parents:
626
diff
changeset
|
900 |
self.RefreshView() |
91b2ae63ea3d
Including external tools for editing plugin informations into Beremiz window
laurent
parents:
626
diff
changeset
|
901 |
|
91b2ae63ea3d
Including external tools for editing plugin informations into Beremiz window
laurent
parents:
626
diff
changeset
|
902 |
def Redo(self): |
91b2ae63ea3d
Including external tools for editing plugin informations into Beremiz window
laurent
parents:
626
diff
changeset
|
903 |
self.Controler.LoadNext() |
91b2ae63ea3d
Including external tools for editing plugin informations into Beremiz window
laurent
parents:
626
diff
changeset
|
904 |
self.RefreshView() |
91b2ae63ea3d
Including external tools for editing plugin informations into Beremiz window
laurent
parents:
626
diff
changeset
|
905 |
|
91b2ae63ea3d
Including external tools for editing plugin informations into Beremiz window
laurent
parents:
626
diff
changeset
|
906 |
def HasNoModel(self): |
91b2ae63ea3d
Including external tools for editing plugin informations into Beremiz window
laurent
parents:
626
diff
changeset
|
907 |
return False |
91b2ae63ea3d
Including external tools for editing plugin informations into Beremiz window
laurent
parents:
626
diff
changeset
|
908 |
|
91b2ae63ea3d
Including external tools for editing plugin informations into Beremiz window
laurent
parents:
626
diff
changeset
|
909 |
def RefreshView(self): |
91b2ae63ea3d
Including external tools for editing plugin informations into Beremiz window
laurent
parents:
626
diff
changeset
|
910 |
for infos in self.Panels.itervalues(): |
91b2ae63ea3d
Including external tools for editing plugin informations into Beremiz window
laurent
parents:
626
diff
changeset
|
911 |
infos["panel"].RefreshView() |
91b2ae63ea3d
Including external tools for editing plugin informations into Beremiz window
laurent
parents:
626
diff
changeset
|
912 |
|
91b2ae63ea3d
Including external tools for editing plugin informations into Beremiz window
laurent
parents:
626
diff
changeset
|
913 |
def GenPanelButtonCallback(self, name): |
91b2ae63ea3d
Including external tools for editing plugin informations into Beremiz window
laurent
parents:
626
diff
changeset
|
914 |
def PanelButtonCallback(event): |
91b2ae63ea3d
Including external tools for editing plugin informations into Beremiz window
laurent
parents:
626
diff
changeset
|
915 |
self.TogglePanel(name) |
91b2ae63ea3d
Including external tools for editing plugin informations into Beremiz window
laurent
parents:
626
diff
changeset
|
916 |
return PanelButtonCallback |
91b2ae63ea3d
Including external tools for editing plugin informations into Beremiz window
laurent
parents:
626
diff
changeset
|
917 |
|
91b2ae63ea3d
Including external tools for editing plugin informations into Beremiz window
laurent
parents:
626
diff
changeset
|
918 |
def ExpandPanel(self, name): |
91b2ae63ea3d
Including external tools for editing plugin informations into Beremiz window
laurent
parents:
626
diff
changeset
|
919 |
infos = self.Panels.get(name, None) |
91b2ae63ea3d
Including external tools for editing plugin informations into Beremiz window
laurent
parents:
626
diff
changeset
|
920 |
if infos is not None and not infos["expanded"]: |
91b2ae63ea3d
Including external tools for editing plugin informations into Beremiz window
laurent
parents:
626
diff
changeset
|
921 |
infos["expanded"] = True |
91b2ae63ea3d
Including external tools for editing plugin informations into Beremiz window
laurent
parents:
626
diff
changeset
|
922 |
infos["button"].SetToggle(True) |
91b2ae63ea3d
Including external tools for editing plugin informations into Beremiz window
laurent
parents:
626
diff
changeset
|
923 |
infos["panel"].Show() |
91b2ae63ea3d
Including external tools for editing plugin informations into Beremiz window
laurent
parents:
626
diff
changeset
|
924 |
self.MainSizer.AddGrowableRow(infos["row"]) |
91b2ae63ea3d
Including external tools for editing plugin informations into Beremiz window
laurent
parents:
626
diff
changeset
|
925 |
|
91b2ae63ea3d
Including external tools for editing plugin informations into Beremiz window
laurent
parents:
626
diff
changeset
|
926 |
self.RefreshSizerLayout() |
91b2ae63ea3d
Including external tools for editing plugin informations into Beremiz window
laurent
parents:
626
diff
changeset
|
927 |
|
91b2ae63ea3d
Including external tools for editing plugin informations into Beremiz window
laurent
parents:
626
diff
changeset
|
928 |
def CollapsePanel(self, name): |
91b2ae63ea3d
Including external tools for editing plugin informations into Beremiz window
laurent
parents:
626
diff
changeset
|
929 |
infos = self.Panels.get(name, None) |
91b2ae63ea3d
Including external tools for editing plugin informations into Beremiz window
laurent
parents:
626
diff
changeset
|
930 |
if infos is not None and infos["expanded"]: |
91b2ae63ea3d
Including external tools for editing plugin informations into Beremiz window
laurent
parents:
626
diff
changeset
|
931 |
infos["expanded"] = False |
91b2ae63ea3d
Including external tools for editing plugin informations into Beremiz window
laurent
parents:
626
diff
changeset
|
932 |
infos["button"].SetToggle(False) |
91b2ae63ea3d
Including external tools for editing plugin informations into Beremiz window
laurent
parents:
626
diff
changeset
|
933 |
infos["panel"].Hide() |
91b2ae63ea3d
Including external tools for editing plugin informations into Beremiz window
laurent
parents:
626
diff
changeset
|
934 |
self.MainSizer.RemoveGrowableRow(infos["row"]) |
91b2ae63ea3d
Including external tools for editing plugin informations into Beremiz window
laurent
parents:
626
diff
changeset
|
935 |
|
91b2ae63ea3d
Including external tools for editing plugin informations into Beremiz window
laurent
parents:
626
diff
changeset
|
936 |
self.RefreshSizerLayout() |
91b2ae63ea3d
Including external tools for editing plugin informations into Beremiz window
laurent
parents:
626
diff
changeset
|
937 |
|
91b2ae63ea3d
Including external tools for editing plugin informations into Beremiz window
laurent
parents:
626
diff
changeset
|
938 |
def TogglePanel(self, name): |
91b2ae63ea3d
Including external tools for editing plugin informations into Beremiz window
laurent
parents:
626
diff
changeset
|
939 |
infos = self.Panels.get(name, None) |
91b2ae63ea3d
Including external tools for editing plugin informations into Beremiz window
laurent
parents:
626
diff
changeset
|
940 |
if infos is not None: |
91b2ae63ea3d
Including external tools for editing plugin informations into Beremiz window
laurent
parents:
626
diff
changeset
|
941 |
infos["expanded"] = not infos["expanded"] |
91b2ae63ea3d
Including external tools for editing plugin informations into Beremiz window
laurent
parents:
626
diff
changeset
|
942 |
infos["button"].SetToggle(infos["expanded"]) |
91b2ae63ea3d
Including external tools for editing plugin informations into Beremiz window
laurent
parents:
626
diff
changeset
|
943 |
if infos["expanded"]: |
91b2ae63ea3d
Including external tools for editing plugin informations into Beremiz window
laurent
parents:
626
diff
changeset
|
944 |
infos["panel"].Show() |
91b2ae63ea3d
Including external tools for editing plugin informations into Beremiz window
laurent
parents:
626
diff
changeset
|
945 |
self.MainSizer.AddGrowableRow(infos["row"]) |
164 | 946 |
else: |
630
91b2ae63ea3d
Including external tools for editing plugin informations into Beremiz window
laurent
parents:
626
diff
changeset
|
947 |
infos["panel"].Hide() |
91b2ae63ea3d
Including external tools for editing plugin informations into Beremiz window
laurent
parents:
626
diff
changeset
|
948 |
self.MainSizer.RemoveGrowableRow(infos["row"]) |
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
|
949 |
|
630
91b2ae63ea3d
Including external tools for editing plugin informations into Beremiz window
laurent
parents:
626
diff
changeset
|
950 |
self.RefreshSizerLayout() |
91b2ae63ea3d
Including external tools for editing plugin informations into Beremiz window
laurent
parents:
626
diff
changeset
|
951 |
|
91b2ae63ea3d
Including external tools for editing plugin informations into Beremiz window
laurent
parents:
626
diff
changeset
|
952 |
def RefreshSizerLayout(self): |
91b2ae63ea3d
Including external tools for editing plugin informations into Beremiz window
laurent
parents:
626
diff
changeset
|
953 |
expand_spacer = True |
91b2ae63ea3d
Including external tools for editing plugin informations into Beremiz window
laurent
parents:
626
diff
changeset
|
954 |
for infos in self.Panels.itervalues(): |
91b2ae63ea3d
Including external tools for editing plugin informations into Beremiz window
laurent
parents:
626
diff
changeset
|
955 |
expand_spacer = expand_spacer and not infos["expanded"] |
91b2ae63ea3d
Including external tools for editing plugin informations into Beremiz window
laurent
parents:
626
diff
changeset
|
956 |
|
91b2ae63ea3d
Including external tools for editing plugin informations into Beremiz window
laurent
parents:
626
diff
changeset
|
957 |
if self.SpacerExpanded != expand_spacer: |
91b2ae63ea3d
Including external tools for editing plugin informations into Beremiz window
laurent
parents:
626
diff
changeset
|
958 |
self.SpacerExpanded = expand_spacer |
91b2ae63ea3d
Including external tools for editing plugin informations into Beremiz window
laurent
parents:
626
diff
changeset
|
959 |
if expand_spacer: |
91b2ae63ea3d
Including external tools for editing plugin informations into Beremiz window
laurent
parents:
626
diff
changeset
|
960 |
self.Spacer.Show() |
91b2ae63ea3d
Including external tools for editing plugin informations into Beremiz window
laurent
parents:
626
diff
changeset
|
961 |
self.MainSizer.AddGrowableRow(2 * len(CFILE_PARTS)) |
91b2ae63ea3d
Including external tools for editing plugin informations into Beremiz window
laurent
parents:
626
diff
changeset
|
962 |
else: |
91b2ae63ea3d
Including external tools for editing plugin informations into Beremiz window
laurent
parents:
626
diff
changeset
|
963 |
self.Spacer.Hide() |
91b2ae63ea3d
Including external tools for editing plugin informations into Beremiz window
laurent
parents:
626
diff
changeset
|
964 |
self.MainSizer.RemoveGrowableRow(2 * len(CFILE_PARTS)) |
91b2ae63ea3d
Including external tools for editing plugin informations into Beremiz window
laurent
parents:
626
diff
changeset
|
965 |
|
91b2ae63ea3d
Including external tools for editing plugin informations into Beremiz window
laurent
parents:
626
diff
changeset
|
966 |
self.MainSizer.Layout() |
213
d8dc1e51c3bf
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
185
diff
changeset
|
967 |