plugins/c_ext/CFileEditor.py
author laurent
Wed, 14 Dec 2011 15:17:36 +0100
changeset 651 cbeb769b0a56
parent 637 c19557ec2c5a
child 653 21a572d80bd7
permissions -rw-r--r--
Adding support for unifying grid table control elements
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())
94855f7b08a9 Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff changeset
   213
                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
   214
                    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
   215
                        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
   216
                    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
   217
                        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
   218
                        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
   219
                    self.CurrentAction = ("Delete", event.GetPosition())
94855f7b08a9 Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff changeset
   220
        event.Skip()
94855f7b08a9 Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff changeset
   221
    
94855f7b08a9 Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff changeset
   222
    def 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
   223
        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
   224
        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
   225
        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
   226
94855f7b08a9 Improving c_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
    def IsViewing(self, name):
94855f7b08a9 Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff changeset
   228
        return self.Name == name
94855f7b08a9 Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff changeset
   229
94855f7b08a9 Improving c_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
    # 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
   231
    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
   232
        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
   233
        if self.ParentWindow:
94855f7b08a9 Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff changeset
   234
            self.ParentWindow.RefreshTitle()
587
c6354f7fe26e Restore RefreshFileMenu in CFileEditor
Edouard Tisserant
parents: 586
diff changeset
   235
            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
   236
            self.ParentWindow.RefreshEditMenu()
630
91b2ae63ea3d Including external tools for editing plugin informations into Beremiz window
laurent
parents: 626
diff changeset
   237
            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
   238
    
94855f7b08a9 Improving c_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
    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
   240
        self.Controler.StartBuffering()
94855f7b08a9 Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff changeset
   241
        if self.ParentWindow:
94855f7b08a9 Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff changeset
   242
            self.ParentWindow.RefreshTitle()
587
c6354f7fe26e Restore RefreshFileMenu in CFileEditor
Edouard Tisserant
parents: 586
diff changeset
   243
            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
   244
            self.ParentWindow.RefreshEditMenu()
630
91b2ae63ea3d Including external tools for editing plugin informations into Beremiz window
laurent
parents: 626
diff changeset
   245
            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
   246
    
94855f7b08a9 Improving c_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
    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
   248
        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
   249
            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
   250
            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
   251
94855f7b08a9 Improving c_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
    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
   253
        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
   254
        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
   255
        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
   256
        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
   257
        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
   258
        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
   259
        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
   260
        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
   261
            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
   262
        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
   263
            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
   264
        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
   265
        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
   266
        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
   267
        
94855f7b08a9 Improving c_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
        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
   269
630
91b2ae63ea3d Including external tools for editing plugin informations into Beremiz window
laurent
parents: 626
diff changeset
   270
    def DoGetBestSize(self):
91b2ae63ea3d Including external tools for editing plugin informations into Beremiz window
laurent
parents: 626
diff changeset
   271
        return self.ParentWindow.GetPanelBestSize()
91b2ae63ea3d Including external tools for editing plugin informations into Beremiz window
laurent
parents: 626
diff changeset
   272
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
   273
    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
   274
        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
   275
94855f7b08a9 Improving c_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
    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
   277
        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
   278
            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
   279
        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
   280
94855f7b08a9 Improving c_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
        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
   282
            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
   283
94855f7b08a9 Improving c_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
            # 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
   285
            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
   286
                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
   287
##                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
   288
##                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
   289
##                                 '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
   290
##                                 '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
   291
            # 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
   292
            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
   293
                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
   294
94855f7b08a9 Improving c_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
                # 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
   296
                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
   297
        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
   298
            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
   299
            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
   300
94855f7b08a9 Improving c_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
    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
   302
        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
   303
        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
   304
94855f7b08a9 Improving c_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
    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
   306
        # 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
   307
        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
   308
        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
   309
        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
   310
        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
   311
94855f7b08a9 Improving c_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
        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
   313
            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
   314
            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
   315
94855f7b08a9 Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff changeset
   316
        # 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
   317
        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
   318
            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
   319
94855f7b08a9 Improving c_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
        # 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
   321
        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
   322
            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
   323
            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
   324
94855f7b08a9 Improving c_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
            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
   326
                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
   327
94855f7b08a9 Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff changeset
   328
        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
   329
            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
   330
94855f7b08a9 Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff changeset
   331
        if 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
   332
            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
   333
        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
   334
            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
   335
            #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
   336
            #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
   337
            #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
   338
            #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
   339
94855f7b08a9 Improving c_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
94855f7b08a9 Improving c_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
    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
   342
        # 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
   343
        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
   344
            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
   345
                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
   346
            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
   347
                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
   348
94855f7b08a9 Improving c_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
                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
   350
                    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
   351
                        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
   352
                        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
   353
                    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
   354
                        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
   355
                            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
   356
                            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
   357
                        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
   358
                            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
   359
                            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
   360
                    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
   361
                        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
   362
94855f7b08a9 Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff changeset
   363
94855f7b08a9 Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff changeset
   364
    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
   365
        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
   366
        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
   367
94855f7b08a9 Improving c_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
        # 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
   369
        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
   370
            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
   371
                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
   372
                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
   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
        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
   375
94855f7b08a9 Improving c_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
        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
   377
            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
   378
            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
   379
               (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
   380
94855f7b08a9 Improving c_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
                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
   382
                    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
   383
                    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
   384
                    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
   385
                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
   386
                    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
   387
                    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
   388
94855f7b08a9 Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff changeset
   389
                    if 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
   390
                        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
   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
            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
   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
94855f7b08a9 Improving c_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
94855f7b08a9 Improving c_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
    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
   397
        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
   398
        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
   399
94855f7b08a9 Improving c_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
        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
   401
            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
   402
                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
   403
                    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
   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
                    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
   406
            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
   407
                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
   408
                    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
   409
94855f7b08a9 Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff changeset
   410
            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
   411
                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
   412
94855f7b08a9 Improving c_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 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
   414
                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
   415
                    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
   416
                        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
   417
                    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
   418
                        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
   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
                    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
   421
94855f7b08a9 Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff changeset
   422
                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
   423
                    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
   424
                        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
   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 = 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
   427
            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
   428
                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
   429
94855f7b08a9 Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff changeset
   430
        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
   431
637
c19557ec2c5a Fixing bug preventing copy/cut/paste using shortcuts on CFileEditor text editors
laurent
parents: 630
diff changeset
   432
    def Cut(self):
c19557ec2c5a Fixing bug preventing copy/cut/paste using shortcuts on CFileEditor text editors
laurent
parents: 630
diff changeset
   433
        self.ResetBuffer()
c19557ec2c5a Fixing bug preventing copy/cut/paste using shortcuts on CFileEditor text editors
laurent
parents: 630
diff changeset
   434
        self.DisableEvents = True
c19557ec2c5a Fixing bug preventing copy/cut/paste using shortcuts on CFileEditor text editors
laurent
parents: 630
diff changeset
   435
        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
   436
        self.DisableEvents = False
c19557ec2c5a Fixing bug preventing copy/cut/paste using shortcuts on CFileEditor text editors
laurent
parents: 630
diff changeset
   437
        self.RefreshModel()
c19557ec2c5a Fixing bug preventing copy/cut/paste using shortcuts on CFileEditor text editors
laurent
parents: 630
diff changeset
   438
        self.RefreshBuffer()
c19557ec2c5a Fixing bug preventing copy/cut/paste using shortcuts on CFileEditor text editors
laurent
parents: 630
diff changeset
   439
    
c19557ec2c5a Fixing bug preventing copy/cut/paste using shortcuts on CFileEditor text editors
laurent
parents: 630
diff changeset
   440
    def Copy(self):
c19557ec2c5a Fixing bug preventing copy/cut/paste using shortcuts on CFileEditor text editors
laurent
parents: 630
diff changeset
   441
        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
   442
    
c19557ec2c5a Fixing bug preventing copy/cut/paste using shortcuts on CFileEditor text editors
laurent
parents: 630
diff changeset
   443
    def Paste(self):
c19557ec2c5a Fixing bug preventing copy/cut/paste using shortcuts on CFileEditor text editors
laurent
parents: 630
diff changeset
   444
        self.ResetBuffer()
c19557ec2c5a Fixing bug preventing copy/cut/paste using shortcuts on CFileEditor text editors
laurent
parents: 630
diff changeset
   445
        self.DisableEvents = True
c19557ec2c5a Fixing bug preventing copy/cut/paste using shortcuts on CFileEditor text editors
laurent
parents: 630
diff changeset
   446
        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
   447
        self.DisableEvents = False
c19557ec2c5a Fixing bug preventing copy/cut/paste using shortcuts on CFileEditor text editors
laurent
parents: 630
diff changeset
   448
        self.RefreshModel()
c19557ec2c5a Fixing bug preventing copy/cut/paste using shortcuts on CFileEditor text editors
laurent
parents: 630
diff changeset
   449
        self.RefreshBuffer()
c19557ec2c5a Fixing bug preventing copy/cut/paste using shortcuts on CFileEditor text editors
laurent
parents: 630
diff changeset
   450
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
   451
94855f7b08a9 Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff changeset
   452
#-------------------------------------------------------------------------------
94855f7b08a9 Improving c_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
#                         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
   454
#-------------------------------------------------------------------------------
94855f7b08a9 Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff changeset
   455
651
cbeb769b0a56 Adding support for unifying grid table control elements
laurent
parents: 637
diff changeset
   456
class VariablesTable(CustomTable):
cbeb769b0a56 Adding support for unifying grid table control elements
laurent
parents: 637
diff changeset
   457
    
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
   458
    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
   459
        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
   460
            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
   461
                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
   462
            else:
651
cbeb769b0a56 Adding support for unifying grid table control elements
laurent
parents: 637
diff changeset
   463
                return str(self.data[row].get(self.GetColLabelValue(col, False), ""))
cbeb769b0a56 Adding support for unifying grid table control elements
laurent
parents: 637
diff changeset
   464
    
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
   465
    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
   466
        """
94855f7b08a9 Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff changeset
   467
        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
   468
        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
   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
        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
   471
        """
94855f7b08a9 Improving c_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
        
94855f7b08a9 Improving c_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
        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
   474
        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
   475
        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
   476
            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
   477
                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
   478
                renderer = None
94855f7b08a9 Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff changeset
   479
                colname = self.GetColLabelValue(col)
94855f7b08a9 Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff changeset
   480
                grid.SetReadOnly(row, col, False)
94855f7b08a9 Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff changeset
   481
                
94855f7b08a9 Improving c_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
                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
   483
                    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
   484
                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
   485
                    editor = wx.grid.GridCellChoiceEditor()
603
e1ef99c609eb added memory location support to C file pluguin
Edouard Tisserant
parents: 587
diff changeset
   486
                    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
   487
                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
   488
                    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
   489
                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
   490
                    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
   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.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
   493
                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
   494
                
94855f7b08a9 Improving c_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
                grid.SetCellBackgroundColour(row, col, wx.WHITE)
651
cbeb769b0a56 Adding support for unifying grid table control elements
laurent
parents: 637
diff changeset
   496
            self.ResizeRow(grid, row)
cbeb769b0a56 Adding support for unifying grid table control elements
laurent
parents: 637
diff changeset
   497
    
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
   498
94855f7b08a9 Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff changeset
   499
[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
   500
 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
   501
 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
   502
] = [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
   503
94855f7b08a9 Improving c_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
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
   505
    
94855f7b08a9 Improving c_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
    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
   507
        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
   508
            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
   509
                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
   510
            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
   511
                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
   512
    
94855f7b08a9 Improving c_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
    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
   514
        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
   515
        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
   516
94855f7b08a9 Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff changeset
   517
    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
   518
        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
   519
        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
   520
94855f7b08a9 Improving c_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
    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
   522
        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
   523
        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
   524
94855f7b08a9 Improving c_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
    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
   526
        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
   527
        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
   528
        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
   529
        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
   530
94855f7b08a9 Improving c_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
    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
   532
        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
   533
        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
   534
        
94855f7b08a9 Improving c_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_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
   536
        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
   537
        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
   538
        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
   539
        
94855f7b08a9 Improving c_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
        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
   541
94855f7b08a9 Improving c_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
    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
   543
        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
   544
              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
   545
        
626
2b9bd5dcf8d2 Adding support for using keyboard to edit cfile interface variables displayed in Grid
laurent
parents: 610
diff changeset
   546
        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
   547
              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
   548
              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
   549
        self.VariablesGrid.SetFont(wx.Font(12, 77, wx.NORMAL, wx.NORMAL, False,
94855f7b08a9 Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff changeset
   550
              'Sans'))
94855f7b08a9 Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff changeset
   551
        self.VariablesGrid.SetLabelFont(wx.Font(10, 77, wx.NORMAL, wx.NORMAL,
94855f7b08a9 Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff changeset
   552
              False, 'Sans'))
94855f7b08a9 Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff changeset
   553
        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
   554
            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
   555
            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
   556
            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
   557
        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
   558
            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
   559
            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
   560
            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
   561
        
94855f7b08a9 Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff changeset
   562
        self.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
   563
              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
   564
              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
   565
        
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
   566
        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
   567
              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
   568
              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
   569
        
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
   570
        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
   571
              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
   572
              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
   573
        
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
   574
        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
   575
              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
   576
              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
   577
        
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
   578
        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
   579
94855f7b08a9 Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff changeset
   580
    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
   581
        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
   582
        
94855f7b08a9 Improving c_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.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
   584
        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
   585
        
94855f7b08a9 Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff changeset
   586
        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
   587
        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
   588
        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
   589
        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
   590
        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
   591
        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
   592
                                       "Delete": self.DeleteVariableButton,
2b9bd5dcf8d2 Adding support for using keyboard to edit cfile interface variables displayed in Grid
laurent
parents: 610
diff changeset
   593
                                       "Up": self.UpVariableButton,
2b9bd5dcf8d2 Adding support for using keyboard to edit cfile interface variables displayed in Grid
laurent
parents: 610
diff changeset
   594
                                       "Down": self.DownVariableButton})
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 _AddVariable(new_row):
2b9bd5dcf8d2 Adding support for using keyboard to edit cfile interface variables displayed in Grid
laurent
parents: 610
diff changeset
   597
            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
   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
            return new_row
2b9bd5dcf8d2 Adding support for using keyboard to edit cfile interface variables displayed in Grid
laurent
parents: 610
diff changeset
   601
        setattr(self.VariablesGrid, "_AddRow", _AddVariable)
2b9bd5dcf8d2 Adding support for using keyboard to edit cfile interface variables displayed in Grid
laurent
parents: 610
diff changeset
   602
        
2b9bd5dcf8d2 Adding support for using keyboard to edit cfile interface variables displayed in Grid
laurent
parents: 610
diff changeset
   603
        def _DeleteVariable(row):
2b9bd5dcf8d2 Adding support for using keyboard to edit cfile interface variables displayed in Grid
laurent
parents: 610
diff changeset
   604
            self.Table.RemoveRow(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
        setattr(self.VariablesGrid, "_DeleteRow", _DeleteVariable)
2b9bd5dcf8d2 Adding support for using keyboard to edit cfile interface variables displayed in Grid
laurent
parents: 610
diff changeset
   608
        
2b9bd5dcf8d2 Adding support for using keyboard to edit cfile interface variables displayed in Grid
laurent
parents: 610
diff changeset
   609
        def _MoveVariable(row, move):
2b9bd5dcf8d2 Adding support for using keyboard to edit cfile interface variables displayed in Grid
laurent
parents: 610
diff changeset
   610
            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
   611
            if new_row != row:
2b9bd5dcf8d2 Adding support for using keyboard to edit cfile interface variables displayed in Grid
laurent
parents: 610
diff changeset
   612
                self.RefreshModel()
2b9bd5dcf8d2 Adding support for using keyboard to edit cfile interface variables displayed in Grid
laurent
parents: 610
diff changeset
   613
                self.RefreshView()
2b9bd5dcf8d2 Adding support for using keyboard to edit cfile interface variables displayed in Grid
laurent
parents: 610
diff changeset
   614
            return new_row
2b9bd5dcf8d2 Adding support for using keyboard to edit cfile interface variables displayed in Grid
laurent
parents: 610
diff changeset
   615
        setattr(self.VariablesGrid, "_MoveRow", _MoveVariable)
2b9bd5dcf8d2 Adding support for using keyboard to edit cfile interface variables displayed in Grid
laurent
parents: 610
diff changeset
   616
        
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
   617
        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
   618
        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
   619
            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
   620
            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
   621
            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
   622
            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
   623
        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
   624
94855f7b08a9 Improving c_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
    def IsViewing(self, name):
94855f7b08a9 Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff changeset
   626
        return name == "Variables"
94855f7b08a9 Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff changeset
   627
94855f7b08a9 Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff changeset
   628
    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
   629
        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
   630
        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
   631
        
94855f7b08a9 Improving c_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
    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
   633
        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
   634
94855f7b08a9 Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff changeset
   635
    # 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
   636
    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
   637
        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
   638
        self.ParentWindow.RefreshTitle()
587
c6354f7fe26e Restore RefreshFileMenu in CFileEditor
Edouard Tisserant
parents: 586
diff changeset
   639
        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
   640
        self.ParentWindow.RefreshEditMenu()
630
91b2ae63ea3d Including external tools for editing plugin informations into Beremiz window
laurent
parents: 626
diff changeset
   641
        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
   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 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
   644
        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
   645
        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
   646
        self.VariablesGrid.RefreshButtons()
2b9bd5dcf8d2 Adding support for using keyboard to edit cfile interface variables displayed in Grid
laurent
parents: 610
diff changeset
   647
    
630
91b2ae63ea3d Including external tools for editing plugin informations into Beremiz window
laurent
parents: 626
diff changeset
   648
    def DoGetBestSize(self):
91b2ae63ea3d Including external tools for editing plugin informations into Beremiz window
laurent
parents: 626
diff changeset
   649
        return self.ParentWindow.GetPanelBestSize()
91b2ae63ea3d Including external tools for editing plugin informations into Beremiz window
laurent
parents: 626
diff changeset
   650
    
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
   651
    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
   652
        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
   653
        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
   654
        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
   655
94855f7b08a9 Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff changeset
   656
    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
   657
        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
   658
        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
   659
            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
   660
            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
   661
            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
   662
                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
   663
                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
   664
                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
   665
            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
   666
            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
   667
            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
   668
                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
   669
                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
   670
                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
   671
            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
   672
            rect = self.VariablesGrid.BlockToDeviceRect((row, col), (row, col))
94855f7b08a9 Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff changeset
   673
            self.VariablesGrid.PopupMenuXY(type_menu, rect.x + rect.width, rect.y + self.VariablesGrid.GetColLabelSize())
94855f7b08a9 Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff changeset
   674
            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
   675
        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
   676
            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
   677
94855f7b08a9 Improving c_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
    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
   679
        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
   680
            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
   681
            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
   682
            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
   683
            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
   684
            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
   685
            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
   686
        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
   687
94855f7b08a9 Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff changeset
   688
    def 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
   689
        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
   690
            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
   691
            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
   692
            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
   693
                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
   694
                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
   695
                    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
   696
                        num += 1
603
e1ef99c609eb added memory location support to C file pluguin
Edouard Tisserant
parents: 587
diff changeset
   697
            elif self.Table.GetValueByName(row, "Class") == "memory":
e1ef99c609eb added memory location support to C file pluguin
Edouard Tisserant
parents: 587
diff changeset
   698
                dir = "%M"
e1ef99c609eb added memory location support to C file pluguin
Edouard Tisserant
parents: 587
diff changeset
   699
                for i in xrange(row):
e1ef99c609eb added memory location support to C file pluguin
Edouard Tisserant
parents: 587
diff changeset
   700
                    if self.Table.GetValueByName(i, "Class") == "memory":
e1ef99c609eb added memory location support to C file pluguin
Edouard Tisserant
parents: 587
diff changeset
   701
                        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
   702
            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
   703
                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
   704
                for i in xrange(row):
161
faad68924b53 Bug on output variable location generation fixed
lbessard
parents: 145
diff changeset
   705
                    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
   706
                        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
   707
            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
   708
            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
   709
            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
   710
            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
   711
            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
   712
            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
   713
            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
   714
            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
   715
        event.Skip()
94855f7b08a9 Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff changeset
   716
    
94855f7b08a9 Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff changeset
   717
94855f7b08a9 Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff changeset
   718
#-------------------------------------------------------------------------------
94855f7b08a9 Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff changeset
   719
#                          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
   720
#-------------------------------------------------------------------------------
94855f7b08a9 Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff changeset
   721
630
91b2ae63ea3d Including external tools for editing plugin informations into Beremiz window
laurent
parents: 626
diff changeset
   722
CFILE_PARTS = [
91b2ae63ea3d Including external tools for editing plugin informations into Beremiz window
laurent
parents: 626
diff changeset
   723
    ("Includes", CppEditor), 
91b2ae63ea3d Including external tools for editing plugin informations into Beremiz window
laurent
parents: 626
diff changeset
   724
    ("Variables", VariablesEditor), 
91b2ae63ea3d Including external tools for editing plugin informations into Beremiz window
laurent
parents: 626
diff changeset
   725
    ("Globals", CppEditor), 
91b2ae63ea3d Including external tools for editing plugin informations into Beremiz window
laurent
parents: 626
diff changeset
   726
    ("Init", CppEditor), 
91b2ae63ea3d Including external tools for editing plugin informations into Beremiz window
laurent
parents: 626
diff changeset
   727
    ("CleanUp", CppEditor), 
91b2ae63ea3d Including external tools for editing plugin informations into Beremiz window
laurent
parents: 626
diff changeset
   728
    ("Retrieve", CppEditor), 
91b2ae63ea3d Including external tools for editing plugin informations into Beremiz window
laurent
parents: 626
diff changeset
   729
    ("Publish", CppEditor),
91b2ae63ea3d Including external tools for editing plugin informations into Beremiz window
laurent
parents: 626
diff changeset
   730
]
91b2ae63ea3d Including external tools for editing plugin informations into Beremiz window
laurent
parents: 626
diff changeset
   731
91b2ae63ea3d Including external tools for editing plugin informations into Beremiz window
laurent
parents: 626
diff changeset
   732
#----------------------------------------------------------------------
91b2ae63ea3d Including external tools for editing plugin informations into Beremiz window
laurent
parents: 626
diff changeset
   733
# different icons for the collapsed/expanded states.
91b2ae63ea3d Including external tools for editing plugin informations into Beremiz window
laurent
parents: 626
diff changeset
   734
# Taken from standard Windows XP collapsed/expanded states.
91b2ae63ea3d Including external tools for editing plugin informations into Beremiz window
laurent
parents: 626
diff changeset
   735
#----------------------------------------------------------------------
91b2ae63ea3d Including external tools for editing plugin informations into Beremiz window
laurent
parents: 626
diff changeset
   736
91b2ae63ea3d Including external tools for editing plugin informations into Beremiz window
laurent
parents: 626
diff changeset
   737
def GetCollapsedIconData():
91b2ae63ea3d Including external tools for editing plugin informations into Beremiz window
laurent
parents: 626
diff changeset
   738
    return \
91b2ae63ea3d Including external tools for editing plugin informations into Beremiz window
laurent
parents: 626
diff changeset
   739
'\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
   740
\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
   741
\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
   742
\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
   743
\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
   744
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
   745
\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
   746
\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
   747
\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
   748
\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
   749
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
   750
\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
   751
~\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
   752
\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
   753
\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
   754
\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
   755
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
   756
\x00\x00\x00IEND\xaeB`\x82' 
91b2ae63ea3d Including external tools for editing plugin informations into Beremiz window
laurent
parents: 626
diff changeset
   757
91b2ae63ea3d Including external tools for editing plugin informations into Beremiz window
laurent
parents: 626
diff changeset
   758
def GetCollapsedIconBitmap():
91b2ae63ea3d Including external tools for editing plugin informations into Beremiz window
laurent
parents: 626
diff changeset
   759
    return wx.BitmapFromImage(GetCollapsedIconImage())
91b2ae63ea3d Including external tools for editing plugin informations into Beremiz window
laurent
parents: 626
diff changeset
   760
91b2ae63ea3d Including external tools for editing plugin informations into Beremiz window
laurent
parents: 626
diff changeset
   761
def GetCollapsedIconImage():
91b2ae63ea3d Including external tools for editing plugin informations into Beremiz window
laurent
parents: 626
diff changeset
   762
    import cStringIO
91b2ae63ea3d Including external tools for editing plugin informations into Beremiz window
laurent
parents: 626
diff changeset
   763
    stream = cStringIO.StringIO(GetCollapsedIconData())
91b2ae63ea3d Including external tools for editing plugin informations into Beremiz window
laurent
parents: 626
diff changeset
   764
    return wx.ImageFromStream(stream)
91b2ae63ea3d Including external tools for editing plugin informations into Beremiz window
laurent
parents: 626
diff changeset
   765
91b2ae63ea3d Including external tools for editing plugin informations into Beremiz window
laurent
parents: 626
diff changeset
   766
#----------------------------------------------------------------------
91b2ae63ea3d Including external tools for editing plugin informations into Beremiz window
laurent
parents: 626
diff changeset
   767
def GetExpandedIconData():
91b2ae63ea3d Including external tools for editing plugin informations into Beremiz window
laurent
parents: 626
diff changeset
   768
    return \
91b2ae63ea3d Including external tools for editing plugin informations into Beremiz window
laurent
parents: 626
diff changeset
   769
'\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
   770
\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
   771
\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
   772
\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
   773
\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
   774
\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
   775
\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
   776
\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
   777
\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
   778
\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
   779
\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
   780
\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
   781
\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
   782
\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
   783
\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
   784
[\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
   785
\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
   786
\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
   787
\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
   788
`\x82' 
91b2ae63ea3d Including external tools for editing plugin informations into Beremiz window
laurent
parents: 626
diff changeset
   789
91b2ae63ea3d Including external tools for editing plugin informations into Beremiz window
laurent
parents: 626
diff changeset
   790
def GetExpandedIconBitmap():
91b2ae63ea3d Including external tools for editing plugin informations into Beremiz window
laurent
parents: 626
diff changeset
   791
    return wx.BitmapFromImage(GetExpandedIconImage())
91b2ae63ea3d Including external tools for editing plugin informations into Beremiz window
laurent
parents: 626
diff changeset
   792
91b2ae63ea3d Including external tools for editing plugin informations into Beremiz window
laurent
parents: 626
diff changeset
   793
def GetExpandedIconImage():
91b2ae63ea3d Including external tools for editing plugin informations into Beremiz window
laurent
parents: 626
diff changeset
   794
    import cStringIO
91b2ae63ea3d Including external tools for editing plugin informations into Beremiz window
laurent
parents: 626
diff changeset
   795
    stream = cStringIO.StringIO(GetExpandedIconData())
91b2ae63ea3d Including external tools for editing plugin informations into Beremiz window
laurent
parents: 626
diff changeset
   796
    return wx.ImageFromStream(stream)
91b2ae63ea3d Including external tools for editing plugin informations into Beremiz window
laurent
parents: 626
diff changeset
   797
91b2ae63ea3d Including external tools for editing plugin informations into Beremiz window
laurent
parents: 626
diff changeset
   798
class FoldPanelCaption(wx.lib.buttons.GenBitmapTextToggleButton):
91b2ae63ea3d Including external tools for editing plugin informations into Beremiz window
laurent
parents: 626
diff changeset
   799
    
91b2ae63ea3d Including external tools for editing plugin informations into Beremiz window
laurent
parents: 626
diff changeset
   800
    def GetBackgroundBrush(self, dc):
91b2ae63ea3d Including external tools for editing plugin informations into Beremiz window
laurent
parents: 626
diff changeset
   801
        colBg = self.GetBackgroundColour()
91b2ae63ea3d Including external tools for editing plugin informations into Beremiz window
laurent
parents: 626
diff changeset
   802
        brush = wx.Brush(colBg, wx.SOLID)
91b2ae63ea3d Including external tools for editing plugin informations into Beremiz window
laurent
parents: 626
diff changeset
   803
        if self.style & wx.BORDER_NONE:
91b2ae63ea3d Including external tools for editing plugin informations into Beremiz window
laurent
parents: 626
diff changeset
   804
            myAttr = self.GetDefaultAttributes()
91b2ae63ea3d Including external tools for editing plugin informations into Beremiz window
laurent
parents: 626
diff changeset
   805
            parAttr = self.GetParent().GetDefaultAttributes()
91b2ae63ea3d Including external tools for editing plugin informations into Beremiz window
laurent
parents: 626
diff changeset
   806
            myDef = colBg == myAttr.colBg
91b2ae63ea3d Including external tools for editing plugin informations into Beremiz window
laurent
parents: 626
diff changeset
   807
            parDef = self.GetParent().GetBackgroundColour() == parAttr.colBg
91b2ae63ea3d Including external tools for editing plugin informations into Beremiz window
laurent
parents: 626
diff changeset
   808
            if myDef and parDef:
91b2ae63ea3d Including external tools for editing plugin informations into Beremiz window
laurent
parents: 626
diff changeset
   809
                if wx.Platform == "__WXMAC__":
91b2ae63ea3d Including external tools for editing plugin informations into Beremiz window
laurent
parents: 626
diff changeset
   810
                    brush.MacSetTheme(1) # 1 == kThemeBrushDialogBackgroundActive
91b2ae63ea3d Including external tools for editing plugin informations into Beremiz window
laurent
parents: 626
diff changeset
   811
                elif wx.Platform == "__WXMSW__":
91b2ae63ea3d Including external tools for editing plugin informations into Beremiz window
laurent
parents: 626
diff changeset
   812
                    if self.DoEraseBackground(dc):
91b2ae63ea3d Including external tools for editing plugin informations into Beremiz window
laurent
parents: 626
diff changeset
   813
                        brush = None
91b2ae63ea3d Including external tools for editing plugin informations into Beremiz window
laurent
parents: 626
diff changeset
   814
            elif myDef and not parDef:
91b2ae63ea3d Including external tools for editing plugin informations into Beremiz window
laurent
parents: 626
diff changeset
   815
                colBg = self.GetParent().GetBackgroundColour()
91b2ae63ea3d Including external tools for editing plugin informations into Beremiz window
laurent
parents: 626
diff changeset
   816
                brush = wx.Brush(colBg, wx.SOLID)
91b2ae63ea3d Including external tools for editing plugin informations into Beremiz window
laurent
parents: 626
diff changeset
   817
        return brush
91b2ae63ea3d Including external tools for editing plugin informations into Beremiz window
laurent
parents: 626
diff changeset
   818
    
91b2ae63ea3d Including external tools for editing plugin informations into Beremiz window
laurent
parents: 626
diff changeset
   819
    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
   820
        bmp = self.bmpLabel
91b2ae63ea3d Including external tools for editing plugin informations into Beremiz window
laurent
parents: 626
diff changeset
   821
        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
   822
            if self.bmpDisabled and not self.IsEnabled():
91b2ae63ea3d Including external tools for editing plugin informations into Beremiz window
laurent
parents: 626
diff changeset
   823
                bmp = self.bmpDisabled
91b2ae63ea3d Including external tools for editing plugin informations into Beremiz window
laurent
parents: 626
diff changeset
   824
            if self.bmpFocus and self.hasFocus:
91b2ae63ea3d Including external tools for editing plugin informations into Beremiz window
laurent
parents: 626
diff changeset
   825
                bmp = self.bmpFocus
91b2ae63ea3d Including external tools for editing plugin informations into Beremiz window
laurent
parents: 626
diff changeset
   826
            if self.bmpSelected and not self.up:
91b2ae63ea3d Including external tools for editing plugin informations into Beremiz window
laurent
parents: 626
diff changeset
   827
                bmp = self.bmpSelected
91b2ae63ea3d Including external tools for editing plugin informations into Beremiz window
laurent
parents: 626
diff changeset
   828
            bw,bh = bmp.GetWidth(), bmp.GetHeight()
91b2ae63ea3d Including external tools for editing plugin informations into Beremiz window
laurent
parents: 626
diff changeset
   829
            hasMask = bmp.GetMask() is not None
91b2ae63ea3d Including external tools for editing plugin informations into Beremiz window
laurent
parents: 626
diff changeset
   830
        else:
91b2ae63ea3d Including external tools for editing plugin informations into Beremiz window
laurent
parents: 626
diff changeset
   831
            bw = bh = 0     # no bitmap -> size is zero
91b2ae63ea3d Including external tools for editing plugin informations into Beremiz window
laurent
parents: 626
diff changeset
   832
        
91b2ae63ea3d Including external tools for editing plugin informations into Beremiz window
laurent
parents: 626
diff changeset
   833
        dc.SetFont(self.GetFont())
91b2ae63ea3d Including external tools for editing plugin informations into Beremiz window
laurent
parents: 626
diff changeset
   834
        if self.IsEnabled():
91b2ae63ea3d Including external tools for editing plugin informations into Beremiz window
laurent
parents: 626
diff changeset
   835
            dc.SetTextForeground(self.GetForegroundColour())
91b2ae63ea3d Including external tools for editing plugin informations into Beremiz window
laurent
parents: 626
diff changeset
   836
        else:
91b2ae63ea3d Including external tools for editing plugin informations into Beremiz window
laurent
parents: 626
diff changeset
   837
            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
   838
91b2ae63ea3d Including external tools for editing plugin informations into Beremiz window
laurent
parents: 626
diff changeset
   839
        label = self.GetLabel()
91b2ae63ea3d Including external tools for editing plugin informations into Beremiz window
laurent
parents: 626
diff changeset
   840
        tw, th = dc.GetTextExtent(label)        # size of text
91b2ae63ea3d Including external tools for editing plugin informations into Beremiz window
laurent
parents: 626
diff changeset
   841
        
91b2ae63ea3d Including external tools for editing plugin informations into Beremiz window
laurent
parents: 626
diff changeset
   842
        if bmp is not None:
91b2ae63ea3d Including external tools for editing plugin informations into Beremiz window
laurent
parents: 626
diff changeset
   843
            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
   844
        
91b2ae63ea3d Including external tools for editing plugin informations into Beremiz window
laurent
parents: 626
diff changeset
   845
        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
   846
91b2ae63ea3d Including external tools for editing plugin informations into Beremiz window
laurent
parents: 626
diff changeset
   847
        dc.SetPen(wx.Pen(self.GetForegroundColour()))
91b2ae63ea3d Including external tools for editing plugin informations into Beremiz window
laurent
parents: 626
diff changeset
   848
        dc.SetBrush(wx.TRANSPARENT_BRUSH)
91b2ae63ea3d Including external tools for editing plugin informations into Beremiz window
laurent
parents: 626
diff changeset
   849
        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
   850
94855f7b08a9 Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff changeset
   851
[ID_CFILEEDITOR, ID_CFILEEDITORMAINSPLITTER, 
164
072e81cc65fe Bug on wx2.6 with PartsOpened fixed
lbessard
parents: 161
diff changeset
   852
 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
   853
] = [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
   854
630
91b2ae63ea3d Including external tools for editing plugin informations into Beremiz window
laurent
parents: 626
diff changeset
   855
class CFileEditor(EditorPanel):
91b2ae63ea3d Including external tools for editing plugin informations into Beremiz window
laurent
parents: 626
diff changeset
   856
    
91b2ae63ea3d Including external tools for editing plugin informations into Beremiz window
laurent
parents: 626
diff changeset
   857
    def _init_Editor(self, prnt):
91b2ae63ea3d Including external tools for editing plugin informations into Beremiz window
laurent
parents: 626
diff changeset
   858
        self.Editor = wx.Panel(id=-1, parent=prnt, pos=wx.Point(0, 0), 
91b2ae63ea3d Including external tools for editing plugin informations into Beremiz window
laurent
parents: 626
diff changeset
   859
                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
   860
        
91b2ae63ea3d Including external tools for editing plugin informations into Beremiz window
laurent
parents: 626
diff changeset
   861
        self.Panels = {}
91b2ae63ea3d Including external tools for editing plugin informations into Beremiz window
laurent
parents: 626
diff changeset
   862
        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
   863
        self.MainSizer.AddGrowableCol(0)
91b2ae63ea3d Including external tools for editing plugin informations into Beremiz window
laurent
parents: 626
diff changeset
   864
        
91b2ae63ea3d Including external tools for editing plugin informations into Beremiz window
laurent
parents: 626
diff changeset
   865
        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
   866
            button_id = wx.NewId()
91b2ae63ea3d Including external tools for editing plugin informations into Beremiz window
laurent
parents: 626
diff changeset
   867
            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
   868
                  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
   869
                  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
   870
            button.SetBitmapSelected(GetExpandedIconBitmap())
91b2ae63ea3d Including external tools for editing plugin informations into Beremiz window
laurent
parents: 626
diff changeset
   871
            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
   872
            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
   873
            
91b2ae63ea3d Including external tools for editing plugin informations into Beremiz window
laurent
parents: 626
diff changeset
   874
            if panel_class == VariablesEditor:
91b2ae63ea3d Including external tools for editing plugin informations into Beremiz window
laurent
parents: 626
diff changeset
   875
                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
   876
            else:
630
91b2ae63ea3d Including external tools for editing plugin informations into Beremiz window
laurent
parents: 626
diff changeset
   877
                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
   878
            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
   879
            panel.Hide()
91b2ae63ea3d Including external tools for editing plugin informations into Beremiz window
laurent
parents: 626
diff changeset
   880
            
91b2ae63ea3d Including external tools for editing plugin informations into Beremiz window
laurent
parents: 626
diff changeset
   881
            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
   882
        
91b2ae63ea3d Including external tools for editing plugin informations into Beremiz window
laurent
parents: 626
diff changeset
   883
        self.Spacer = wx.Panel(self.Editor, -1)
91b2ae63ea3d Including external tools for editing plugin informations into Beremiz window
laurent
parents: 626
diff changeset
   884
        self.SpacerExpanded = True
91b2ae63ea3d Including external tools for editing plugin informations into Beremiz window
laurent
parents: 626
diff changeset
   885
        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
   886
        
91b2ae63ea3d Including external tools for editing plugin informations into Beremiz window
laurent
parents: 626
diff changeset
   887
        self.MainSizer.AddGrowableRow(2 * len(CFILE_PARTS))
91b2ae63ea3d Including external tools for editing plugin informations into Beremiz window
laurent
parents: 626
diff changeset
   888
        
91b2ae63ea3d Including external tools for editing plugin informations into Beremiz window
laurent
parents: 626
diff changeset
   889
        self.Editor.SetSizer(self.MainSizer)
91b2ae63ea3d Including external tools for editing plugin informations into Beremiz window
laurent
parents: 626
diff changeset
   890
        
91b2ae63ea3d Including external tools for editing plugin informations into Beremiz window
laurent
parents: 626
diff changeset
   891
    def __init__(self, parent, controler, window):
91b2ae63ea3d Including external tools for editing plugin informations into Beremiz window
laurent
parents: 626
diff changeset
   892
        EditorPanel.__init__(self, parent, "", window, controler)
91b2ae63ea3d Including external tools for editing plugin informations into Beremiz window
laurent
parents: 626
diff changeset
   893
        
91b2ae63ea3d Including external tools for editing plugin informations into Beremiz window
laurent
parents: 626
diff changeset
   894
        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
   895
        self.SetIcon(wx.BitmapFromImage(img.Rescale(16, 16)))
91b2ae63ea3d Including external tools for editing plugin informations into Beremiz window
laurent
parents: 626
diff changeset
   896
        
91b2ae63ea3d Including external tools for editing plugin informations into Beremiz window
laurent
parents: 626
diff changeset
   897
    def GetTitle(self):
91b2ae63ea3d Including external tools for editing plugin informations into Beremiz window
laurent
parents: 626
diff changeset
   898
        filename = self.Controler.GetFilename()
91b2ae63ea3d Including external tools for editing plugin informations into Beremiz window
laurent
parents: 626
diff changeset
   899
        if not self.Controler.CFileIsSaved():
91b2ae63ea3d Including external tools for editing plugin informations into Beremiz window
laurent
parents: 626
diff changeset
   900
            return "~%s~" % filename
91b2ae63ea3d Including external tools for editing plugin informations into Beremiz window
laurent
parents: 626
diff changeset
   901
        return filename
91b2ae63ea3d Including external tools for editing plugin informations into Beremiz window
laurent
parents: 626
diff changeset
   902
    
91b2ae63ea3d Including external tools for editing plugin informations into Beremiz window
laurent
parents: 626
diff changeset
   903
    def GetBufferState(self):
91b2ae63ea3d Including external tools for editing plugin informations into Beremiz window
laurent
parents: 626
diff changeset
   904
        return self.Controler.GetBufferState()
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 Undo(self):
91b2ae63ea3d Including external tools for editing plugin informations into Beremiz window
laurent
parents: 626
diff changeset
   907
        self.Controler.LoadPrevious()
91b2ae63ea3d Including external tools for editing plugin informations into Beremiz window
laurent
parents: 626
diff changeset
   908
        self.RefreshView()
91b2ae63ea3d Including external tools for editing plugin informations into Beremiz window
laurent
parents: 626
diff changeset
   909
            
91b2ae63ea3d Including external tools for editing plugin informations into Beremiz window
laurent
parents: 626
diff changeset
   910
    def Redo(self):
91b2ae63ea3d Including external tools for editing plugin informations into Beremiz window
laurent
parents: 626
diff changeset
   911
        self.Controler.LoadNext()
91b2ae63ea3d Including external tools for editing plugin informations into Beremiz window
laurent
parents: 626
diff changeset
   912
        self.RefreshView()
91b2ae63ea3d Including external tools for editing plugin informations into Beremiz window
laurent
parents: 626
diff changeset
   913
    
91b2ae63ea3d Including external tools for editing plugin informations into Beremiz window
laurent
parents: 626
diff changeset
   914
    def HasNoModel(self):
91b2ae63ea3d Including external tools for editing plugin informations into Beremiz window
laurent
parents: 626
diff changeset
   915
        return False
91b2ae63ea3d Including external tools for editing plugin informations into Beremiz window
laurent
parents: 626
diff changeset
   916
91b2ae63ea3d Including external tools for editing plugin informations into Beremiz window
laurent
parents: 626
diff changeset
   917
    def RefreshView(self):
91b2ae63ea3d Including external tools for editing plugin informations into Beremiz window
laurent
parents: 626
diff changeset
   918
        for infos in self.Panels.itervalues():
91b2ae63ea3d Including external tools for editing plugin informations into Beremiz window
laurent
parents: 626
diff changeset
   919
            infos["panel"].RefreshView()
91b2ae63ea3d Including external tools for editing plugin informations into Beremiz window
laurent
parents: 626
diff changeset
   920
91b2ae63ea3d Including external tools for editing plugin informations into Beremiz window
laurent
parents: 626
diff changeset
   921
    def GenPanelButtonCallback(self, name):
91b2ae63ea3d Including external tools for editing plugin informations into Beremiz window
laurent
parents: 626
diff changeset
   922
        def PanelButtonCallback(event):
91b2ae63ea3d Including external tools for editing plugin informations into Beremiz window
laurent
parents: 626
diff changeset
   923
            self.TogglePanel(name)
91b2ae63ea3d Including external tools for editing plugin informations into Beremiz window
laurent
parents: 626
diff changeset
   924
        return PanelButtonCallback
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
    def ExpandPanel(self, name):
91b2ae63ea3d Including external tools for editing plugin informations into Beremiz window
laurent
parents: 626
diff changeset
   927
        infos = self.Panels.get(name, None)
91b2ae63ea3d Including external tools for editing plugin informations into Beremiz window
laurent
parents: 626
diff changeset
   928
        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
   929
            infos["expanded"] = True
91b2ae63ea3d Including external tools for editing plugin informations into Beremiz window
laurent
parents: 626
diff changeset
   930
            infos["button"].SetToggle(True)
91b2ae63ea3d Including external tools for editing plugin informations into Beremiz window
laurent
parents: 626
diff changeset
   931
            infos["panel"].Show()
91b2ae63ea3d Including external tools for editing plugin informations into Beremiz window
laurent
parents: 626
diff changeset
   932
            self.MainSizer.AddGrowableRow(infos["row"])
91b2ae63ea3d Including external tools for editing plugin informations into Beremiz window
laurent
parents: 626
diff changeset
   933
        
91b2ae63ea3d Including external tools for editing plugin informations into Beremiz window
laurent
parents: 626
diff changeset
   934
            self.RefreshSizerLayout()
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
    def CollapsePanel(self, name):
91b2ae63ea3d Including external tools for editing plugin informations into Beremiz window
laurent
parents: 626
diff changeset
   937
        infos = self.Panels.get(name, None)
91b2ae63ea3d Including external tools for editing plugin informations into Beremiz window
laurent
parents: 626
diff changeset
   938
        if infos is not None and infos["expanded"]:
91b2ae63ea3d Including external tools for editing plugin informations into Beremiz window
laurent
parents: 626
diff changeset
   939
            infos["expanded"] = False
91b2ae63ea3d Including external tools for editing plugin informations into Beremiz window
laurent
parents: 626
diff changeset
   940
            infos["button"].SetToggle(False)
91b2ae63ea3d Including external tools for editing plugin informations into Beremiz window
laurent
parents: 626
diff changeset
   941
            infos["panel"].Hide()
91b2ae63ea3d Including external tools for editing plugin informations into Beremiz window
laurent
parents: 626
diff changeset
   942
            self.MainSizer.RemoveGrowableRow(infos["row"])
91b2ae63ea3d Including external tools for editing plugin informations into Beremiz window
laurent
parents: 626
diff changeset
   943
        
91b2ae63ea3d Including external tools for editing plugin informations into Beremiz window
laurent
parents: 626
diff changeset
   944
            self.RefreshSizerLayout()
91b2ae63ea3d Including external tools for editing plugin informations into Beremiz window
laurent
parents: 626
diff changeset
   945
        
91b2ae63ea3d Including external tools for editing plugin informations into Beremiz window
laurent
parents: 626
diff changeset
   946
    def TogglePanel(self, name):
91b2ae63ea3d Including external tools for editing plugin informations into Beremiz window
laurent
parents: 626
diff changeset
   947
        infos = self.Panels.get(name, None)
91b2ae63ea3d Including external tools for editing plugin informations into Beremiz window
laurent
parents: 626
diff changeset
   948
        if infos is not None:
91b2ae63ea3d Including external tools for editing plugin informations into Beremiz window
laurent
parents: 626
diff changeset
   949
            infos["expanded"] = not infos["expanded"]
91b2ae63ea3d Including external tools for editing plugin informations into Beremiz window
laurent
parents: 626
diff changeset
   950
            infos["button"].SetToggle(infos["expanded"])
91b2ae63ea3d Including external tools for editing plugin informations into Beremiz window
laurent
parents: 626
diff changeset
   951
            if infos["expanded"]:
91b2ae63ea3d Including external tools for editing plugin informations into Beremiz window
laurent
parents: 626
diff changeset
   952
                infos["panel"].Show()
91b2ae63ea3d Including external tools for editing plugin informations into Beremiz window
laurent
parents: 626
diff changeset
   953
                self.MainSizer.AddGrowableRow(infos["row"])
164
072e81cc65fe Bug on wx2.6 with PartsOpened fixed
lbessard
parents: 161
diff changeset
   954
            else:
630
91b2ae63ea3d Including external tools for editing plugin informations into Beremiz window
laurent
parents: 626
diff changeset
   955
                infos["panel"].Hide()
91b2ae63ea3d Including external tools for editing plugin informations into Beremiz window
laurent
parents: 626
diff changeset
   956
                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
   957
            
630
91b2ae63ea3d Including external tools for editing plugin informations into Beremiz window
laurent
parents: 626
diff changeset
   958
            self.RefreshSizerLayout()
91b2ae63ea3d Including external tools for editing plugin informations into Beremiz window
laurent
parents: 626
diff changeset
   959
    
91b2ae63ea3d Including external tools for editing plugin informations into Beremiz window
laurent
parents: 626
diff changeset
   960
    def RefreshSizerLayout(self):
91b2ae63ea3d Including external tools for editing plugin informations into Beremiz window
laurent
parents: 626
diff changeset
   961
        expand_spacer = True
91b2ae63ea3d Including external tools for editing plugin informations into Beremiz window
laurent
parents: 626
diff changeset
   962
        for infos in self.Panels.itervalues():
91b2ae63ea3d Including external tools for editing plugin informations into Beremiz window
laurent
parents: 626
diff changeset
   963
            expand_spacer = expand_spacer and not infos["expanded"]
91b2ae63ea3d Including external tools for editing plugin informations into Beremiz window
laurent
parents: 626
diff changeset
   964
        
91b2ae63ea3d Including external tools for editing plugin informations into Beremiz window
laurent
parents: 626
diff changeset
   965
        if self.SpacerExpanded != expand_spacer:
91b2ae63ea3d Including external tools for editing plugin informations into Beremiz window
laurent
parents: 626
diff changeset
   966
            self.SpacerExpanded = expand_spacer
91b2ae63ea3d Including external tools for editing plugin informations into Beremiz window
laurent
parents: 626
diff changeset
   967
            if expand_spacer:
91b2ae63ea3d Including external tools for editing plugin informations into Beremiz window
laurent
parents: 626
diff changeset
   968
                self.Spacer.Show()
91b2ae63ea3d Including external tools for editing plugin informations into Beremiz window
laurent
parents: 626
diff changeset
   969
                self.MainSizer.AddGrowableRow(2 * len(CFILE_PARTS))
91b2ae63ea3d Including external tools for editing plugin informations into Beremiz window
laurent
parents: 626
diff changeset
   970
            else:
91b2ae63ea3d Including external tools for editing plugin informations into Beremiz window
laurent
parents: 626
diff changeset
   971
                self.Spacer.Hide()
91b2ae63ea3d Including external tools for editing plugin informations into Beremiz window
laurent
parents: 626
diff changeset
   972
                self.MainSizer.RemoveGrowableRow(2 * len(CFILE_PARTS))
91b2ae63ea3d Including external tools for editing plugin informations into Beremiz window
laurent
parents: 626
diff changeset
   973
        
91b2ae63ea3d Including external tools for editing plugin informations into Beremiz window
laurent
parents: 626
diff changeset
   974
        self.MainSizer.Layout()
213
d8dc1e51c3bf Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents: 185
diff changeset
   975