c_ext/CFileEditor.py
author Laurent Bessard
Wed, 30 Jan 2013 19:07:59 +0100
changeset 919 4a36e38e51d3
parent 874 8b24e9312f18
child 920 1499a4d225db
permissions -rw-r--r--
Fix bug in DebugVariablePanel when manipulating graph layout and adding drag'n drop graph from parallel graphs and moving graphs order
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
738
413946c04c87 refactoring
laurent
parents: 734
diff changeset
     8
from controls import CustomGrid, CustomTable
814
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents: 801
diff changeset
     9
from editors.ConfTreeNodeEditor import ConfTreeNodeEditor
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents: 801
diff changeset
    10
from util.BitmapLibrary import GetBitmap
626
2b9bd5dcf8d2 Adding support for using keyboard to edit cfile interface variables displayed in Grid
laurent
parents: 610
diff changeset
    11
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
    12
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
    13
    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
    14
              '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
    15
              '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
    16
              '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
    17
              '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
    18
              '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
    19
             }
94855f7b08a9 Improving c_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
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
    21
    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
    22
              '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
    23
              '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
    24
              '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
    25
              '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
    26
              '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
    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
94855f7b08a9 Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff changeset
    29
94855f7b08a9 Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff changeset
    30
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
    31
    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
    32
        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
    33
    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
    34
        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
    35
94855f7b08a9 Improving c_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
94855f7b08a9 Improving c_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
[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
    38
] = [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
    39
94855f7b08a9 Improving c_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
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
    41
    "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
    42
    "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
    43
    "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
    44
    "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
    45
    "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
    46
    "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
    47
    "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
    48
    "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
    49
94855f7b08a9 Improving c_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
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
    51
    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
    52
    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
    53
    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
    54
    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
    55
    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
    56
        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
    57
            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
    58
    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
    59
        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
    60
            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
    61
        else:
94855f7b08a9 Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff changeset
    62
            return 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
    63
    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
    64
        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
    65
            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
    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 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
    68
    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
    69
        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
    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
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
    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
    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
    74
    
94855f7b08a9 Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff changeset
    75
    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
    76
        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
    77
                 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
    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
    79
        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
    80
        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
    81
94855f7b08a9 Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff changeset
    82
        self.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
    83
        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
    84
94855f7b08a9 Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff changeset
    85
        self.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
    86
        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
    87
94855f7b08a9 Improving c_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.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
    89
        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
    90
        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
    91
94855f7b08a9 Improving c_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.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
    93
        #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
    94
        #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
    95
        #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
    96
        #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
    97
        
94855f7b08a9 Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff changeset
    98
        self.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
    99
        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
   100
94855f7b08a9 Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff changeset
   101
        # 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
   102
        #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
   103
        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
   104
        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
   105
        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
   106
        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
   107
94855f7b08a9 Improving c_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
        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
   109
            # 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
   110
            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
   111
            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
   112
            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
   113
            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
   114
            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
   115
            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
   116
            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
   117
            
94855f7b08a9 Improving c_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
        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
   119
            # 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
   120
            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
   121
            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
   122
            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
   123
            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
   124
            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
   125
            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
   126
            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
   127
94855f7b08a9 Improving c_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
        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
   129
            # 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
   130
            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
   131
            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
   132
            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
   133
            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
   134
            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
   135
            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
   136
            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
   137
94855f7b08a9 Improving c_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
        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
   139
            # 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
   140
            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
   141
            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
   142
            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
   143
            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
   144
            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
   145
            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
   146
            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
   147
94855f7b08a9 Improving c_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
94855f7b08a9 Improving c_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(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
   150
        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
   151
        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
   152
94855f7b08a9 Improving c_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
        # 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
   154
        # 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
   155
        # 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
   156
94855f7b08a9 Improving c_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
        # 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
   158
        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
   159
        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
   160
94855f7b08a9 Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff changeset
   161
        # 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
   162
        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
   163
        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
   164
        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
   165
        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
   166
        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
   167
94855f7b08a9 Improving c_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_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
   169
        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
   170
        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
   171
        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
   172
        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
   173
        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
   174
        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
   175
        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
   176
        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
   177
        
94855f7b08a9 Improving c_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
        # 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
   179
        #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
   180
        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
   181
            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
   182
        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
   183
            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
   184
        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
   185
            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
   186
94855f7b08a9 Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff changeset
   187
        # 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
   188
        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
   189
        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
   190
94855f7b08a9 Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff changeset
   191
        self.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
   192
        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
   193
        
94855f7b08a9 Improving c_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.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
   195
        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
   196
        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
   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.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
   199
94855f7b08a9 Improving c_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_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
   201
        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
   202
        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
   203
    
94855f7b08a9 Improving c_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
    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
   205
        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
   206
            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
   207
            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
   208
                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
   209
                    if self.CurrentAction == None:
94855f7b08a9 Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff changeset
   210
                        self.StartBuffering()
94855f7b08a9 Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff changeset
   211
                    elif self.CurrentAction[0] != "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
   212
                        self.Controler.EndBuffering()
94855f7b08a9 Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff changeset
   213
                        self.StartBuffering()
94855f7b08a9 Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff changeset
   214
                    self.CurrentAction = ("Add", event.GetPosition())
658
94417ab25510 Fixing some issues in c_ext plugin
laurent
parents: 656
diff changeset
   215
                    wx.CallAfter(self.RefreshModel)
145
94855f7b08a9 Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff changeset
   216
                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
   217
                    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
   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
                    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
   220
                        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
   221
                        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
   222
                    self.CurrentAction = ("Delete", event.GetPosition())
658
94417ab25510 Fixing some issues in c_ext plugin
laurent
parents: 656
diff changeset
   223
                    wx.CallAfter(self.RefreshModel)
145
94855f7b08a9 Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff changeset
   224
        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
   225
    
94855f7b08a9 Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff changeset
   226
    def 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
   227
        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
   228
        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
   229
        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
   230
94855f7b08a9 Improving c_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
    # 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
   232
    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
   233
        self.Controler.BufferCFile()
658
94417ab25510 Fixing some issues in c_ext plugin
laurent
parents: 656
diff changeset
   234
        if self.ParentWindow is not None:
145
94855f7b08a9 Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff changeset
   235
            self.ParentWindow.RefreshTitle()
587
c6354f7fe26e Restore RefreshFileMenu in CFileEditor
Edouard Tisserant
parents: 586
diff changeset
   236
            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
   237
            self.ParentWindow.RefreshEditMenu()
630
91b2ae63ea3d Including external tools for editing plugin informations into Beremiz window
laurent
parents: 626
diff changeset
   238
            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
   239
    
94855f7b08a9 Improving c_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
    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
   241
        self.Controler.StartBuffering()
658
94417ab25510 Fixing some issues in c_ext plugin
laurent
parents: 656
diff changeset
   242
        if self.ParentWindow is not None:
145
94855f7b08a9 Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff changeset
   243
            self.ParentWindow.RefreshTitle()
587
c6354f7fe26e Restore RefreshFileMenu in CFileEditor
Edouard Tisserant
parents: 586
diff changeset
   244
            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
   245
            self.ParentWindow.RefreshEditMenu()
630
91b2ae63ea3d Including external tools for editing plugin informations into Beremiz window
laurent
parents: 626
diff changeset
   246
            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
   247
    
94855f7b08a9 Improving c_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
    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
   249
        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
   250
            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
   251
            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
   252
94855f7b08a9 Improving c_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
    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
   254
        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
   255
        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
   256
        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
   257
        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
   258
        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
   259
        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
   260
        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
   261
        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
   262
            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
   263
        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
   264
            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
   265
        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
   266
        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
   267
        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
   268
        
94855f7b08a9 Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff changeset
   269
        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
   270
630
91b2ae63ea3d Including external tools for editing plugin informations into Beremiz window
laurent
parents: 626
diff changeset
   271
    def DoGetBestSize(self):
91b2ae63ea3d Including external tools for editing plugin informations into Beremiz window
laurent
parents: 626
diff changeset
   272
        return self.ParentWindow.GetPanelBestSize()
91b2ae63ea3d Including external tools for editing plugin informations into Beremiz window
laurent
parents: 626
diff changeset
   273
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
   274
    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
   275
        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
   276
94855f7b08a9 Improving c_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
    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
   278
        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
   279
            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
   280
        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
   281
94855f7b08a9 Improving c_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
        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
   283
            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
   284
94855f7b08a9 Improving c_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
            # 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
   286
            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
   287
                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
   288
##                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
   289
##                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
   290
##                                 '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
   291
##                                 '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
   292
            # 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
   293
            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
   294
                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
   295
94855f7b08a9 Improving c_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
                # 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
   297
                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
   298
        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
   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
665
aec7aca89f3e Fixing bug in c_ext plugin variable grid cells not editable
laurent
parents: 658
diff changeset
   479
                colname = self.GetColLabelValue(col, False)
145
94855f7b08a9 Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff changeset
   480
                
94855f7b08a9 Improving c_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
                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
   482
                    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
   483
                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
   484
                    editor = wx.grid.GridCellChoiceEditor()
603
e1ef99c609eb added memory location support to C file pluguin
Edouard Tisserant
parents: 587
diff changeset
   485
                    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
   486
                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
   487
                    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
   488
                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
   489
                    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
   490
                
94855f7b08a9 Improving c_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
                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
   492
                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
   493
                
94855f7b08a9 Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff changeset
   494
                grid.SetCellBackgroundColour(row, col, wx.WHITE)
651
cbeb769b0a56 Adding support for unifying grid table control elements
laurent
parents: 637
diff changeset
   495
            self.ResizeRow(grid, row)
848
fe9504c4104e Replacing text buttons by bitmap buttons for variable grid in CFileEditor
laurent
parents: 814
diff changeset
   496
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
   497
94855f7b08a9 Improving c_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
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
   499
    
94855f7b08a9 Improving c_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
    def __init__(self, parent, window, controler):
848
fe9504c4104e Replacing text buttons by bitmap buttons for variable grid in CFileEditor
laurent
parents: 814
diff changeset
   501
        wx.Panel.__init__(self, parent, style=wx.TAB_TRAVERSAL)
fe9504c4104e Replacing text buttons by bitmap buttons for variable grid in CFileEditor
laurent
parents: 814
diff changeset
   502
        
fe9504c4104e Replacing text buttons by bitmap buttons for variable grid in CFileEditor
laurent
parents: 814
diff changeset
   503
        main_sizer = wx.FlexGridSizer(cols=1, hgap=0, rows=2, vgap=4)
fe9504c4104e Replacing text buttons by bitmap buttons for variable grid in CFileEditor
laurent
parents: 814
diff changeset
   504
        main_sizer.AddGrowableCol(0)
fe9504c4104e Replacing text buttons by bitmap buttons for variable grid in CFileEditor
laurent
parents: 814
diff changeset
   505
        main_sizer.AddGrowableRow(0)
fe9504c4104e Replacing text buttons by bitmap buttons for variable grid in CFileEditor
laurent
parents: 814
diff changeset
   506
        
fe9504c4104e Replacing text buttons by bitmap buttons for variable grid in CFileEditor
laurent
parents: 814
diff changeset
   507
        self.VariablesGrid = CustomGrid(self, style=wx.VSCROLL)
fe9504c4104e Replacing text buttons by bitmap buttons for variable grid in CFileEditor
laurent
parents: 814
diff changeset
   508
        self.VariablesGrid.Bind(wx.grid.EVT_GRID_CELL_CHANGE, self.OnVariablesGridCellChange)
fe9504c4104e Replacing text buttons by bitmap buttons for variable grid in CFileEditor
laurent
parents: 814
diff changeset
   509
        self.VariablesGrid.Bind(wx.grid.EVT_GRID_CELL_LEFT_CLICK, self.OnVariablesGridCellLeftClick)
fe9504c4104e Replacing text buttons by bitmap buttons for variable grid in CFileEditor
laurent
parents: 814
diff changeset
   510
        self.VariablesGrid.Bind(wx.grid.EVT_GRID_EDITOR_SHOWN, self.OnVariablesGridEditorShown)
fe9504c4104e Replacing text buttons by bitmap buttons for variable grid in CFileEditor
laurent
parents: 814
diff changeset
   511
        main_sizer.AddWindow(self.VariablesGrid, flag=wx.GROW)
fe9504c4104e Replacing text buttons by bitmap buttons for variable grid in CFileEditor
laurent
parents: 814
diff changeset
   512
        
fe9504c4104e Replacing text buttons by bitmap buttons for variable grid in CFileEditor
laurent
parents: 814
diff changeset
   513
        controls_sizer = wx.BoxSizer(wx.HORIZONTAL)
fe9504c4104e Replacing text buttons by bitmap buttons for variable grid in CFileEditor
laurent
parents: 814
diff changeset
   514
        main_sizer.AddSizer(controls_sizer, border=5, flag=wx.TOP|wx.ALIGN_RIGHT)
fe9504c4104e Replacing text buttons by bitmap buttons for variable grid in CFileEditor
laurent
parents: 814
diff changeset
   515
        
fe9504c4104e Replacing text buttons by bitmap buttons for variable grid in CFileEditor
laurent
parents: 814
diff changeset
   516
        for name, bitmap, help in [
fe9504c4104e Replacing text buttons by bitmap buttons for variable grid in CFileEditor
laurent
parents: 814
diff changeset
   517
                ("AddVariableButton", "add_element", _("Add variable")),
fe9504c4104e Replacing text buttons by bitmap buttons for variable grid in CFileEditor
laurent
parents: 814
diff changeset
   518
                ("DeleteVariableButton", "remove_element", _("Remove variable")),
fe9504c4104e Replacing text buttons by bitmap buttons for variable grid in CFileEditor
laurent
parents: 814
diff changeset
   519
                ("UpVariableButton", "up", _("Move variable up")),
fe9504c4104e Replacing text buttons by bitmap buttons for variable grid in CFileEditor
laurent
parents: 814
diff changeset
   520
                ("DownVariableButton", "down", _("Move variable down"))]:
fe9504c4104e Replacing text buttons by bitmap buttons for variable grid in CFileEditor
laurent
parents: 814
diff changeset
   521
            button = wx.lib.buttons.GenBitmapButton(self, bitmap=GetBitmap(bitmap), 
fe9504c4104e Replacing text buttons by bitmap buttons for variable grid in CFileEditor
laurent
parents: 814
diff changeset
   522
                  size=wx.Size(28, 28), style=wx.NO_BORDER)
fe9504c4104e Replacing text buttons by bitmap buttons for variable grid in CFileEditor
laurent
parents: 814
diff changeset
   523
            button.SetToolTipString(help)
fe9504c4104e Replacing text buttons by bitmap buttons for variable grid in CFileEditor
laurent
parents: 814
diff changeset
   524
            setattr(self, name, button)
fe9504c4104e Replacing text buttons by bitmap buttons for variable grid in CFileEditor
laurent
parents: 814
diff changeset
   525
            controls_sizer.AddWindow(button, border=5, flag=wx.LEFT)
fe9504c4104e Replacing text buttons by bitmap buttons for variable grid in CFileEditor
laurent
parents: 814
diff changeset
   526
        
fe9504c4104e Replacing text buttons by bitmap buttons for variable grid in CFileEditor
laurent
parents: 814
diff changeset
   527
        self.SetSizer(main_sizer)
fe9504c4104e Replacing text buttons by bitmap buttons for variable grid in CFileEditor
laurent
parents: 814
diff changeset
   528
                
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
   529
        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
   530
        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
   531
        
94855f7b08a9 Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff changeset
   532
        self.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
   533
        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
   534
        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
   535
        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
   536
        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
   537
        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
   538
                                       "Delete": self.DeleteVariableButton,
2b9bd5dcf8d2 Adding support for using keyboard to edit cfile interface variables displayed in Grid
laurent
parents: 610
diff changeset
   539
                                       "Up": self.UpVariableButton,
2b9bd5dcf8d2 Adding support for using keyboard to edit cfile interface variables displayed in Grid
laurent
parents: 610
diff changeset
   540
                                       "Down": self.DownVariableButton})
2b9bd5dcf8d2 Adding support for using keyboard to edit cfile interface variables displayed in Grid
laurent
parents: 610
diff changeset
   541
        
2b9bd5dcf8d2 Adding support for using keyboard to edit cfile interface variables displayed in Grid
laurent
parents: 610
diff changeset
   542
        def _AddVariable(new_row):
2b9bd5dcf8d2 Adding support for using keyboard to edit cfile interface variables displayed in Grid
laurent
parents: 610
diff changeset
   543
            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
   544
            self.RefreshModel()
2b9bd5dcf8d2 Adding support for using keyboard to edit cfile interface variables displayed in Grid
laurent
parents: 610
diff changeset
   545
            self.RefreshView()
2b9bd5dcf8d2 Adding support for using keyboard to edit cfile interface variables displayed in Grid
laurent
parents: 610
diff changeset
   546
            return new_row
2b9bd5dcf8d2 Adding support for using keyboard to edit cfile interface variables displayed in Grid
laurent
parents: 610
diff changeset
   547
        setattr(self.VariablesGrid, "_AddRow", _AddVariable)
2b9bd5dcf8d2 Adding support for using keyboard to edit cfile interface variables displayed in Grid
laurent
parents: 610
diff changeset
   548
        
2b9bd5dcf8d2 Adding support for using keyboard to edit cfile interface variables displayed in Grid
laurent
parents: 610
diff changeset
   549
        def _DeleteVariable(row):
2b9bd5dcf8d2 Adding support for using keyboard to edit cfile interface variables displayed in Grid
laurent
parents: 610
diff changeset
   550
            self.Table.RemoveRow(row)
2b9bd5dcf8d2 Adding support for using keyboard to edit cfile interface variables displayed in Grid
laurent
parents: 610
diff changeset
   551
            self.RefreshModel()
2b9bd5dcf8d2 Adding support for using keyboard to edit cfile interface variables displayed in Grid
laurent
parents: 610
diff changeset
   552
            self.RefreshView()
2b9bd5dcf8d2 Adding support for using keyboard to edit cfile interface variables displayed in Grid
laurent
parents: 610
diff changeset
   553
        setattr(self.VariablesGrid, "_DeleteRow", _DeleteVariable)
2b9bd5dcf8d2 Adding support for using keyboard to edit cfile interface variables displayed in Grid
laurent
parents: 610
diff changeset
   554
        
2b9bd5dcf8d2 Adding support for using keyboard to edit cfile interface variables displayed in Grid
laurent
parents: 610
diff changeset
   555
        def _MoveVariable(row, move):
2b9bd5dcf8d2 Adding support for using keyboard to edit cfile interface variables displayed in Grid
laurent
parents: 610
diff changeset
   556
            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
   557
            if new_row != row:
2b9bd5dcf8d2 Adding support for using keyboard to edit cfile interface variables displayed in Grid
laurent
parents: 610
diff changeset
   558
                self.RefreshModel()
2b9bd5dcf8d2 Adding support for using keyboard to edit cfile interface variables displayed in Grid
laurent
parents: 610
diff changeset
   559
                self.RefreshView()
2b9bd5dcf8d2 Adding support for using keyboard to edit cfile interface variables displayed in Grid
laurent
parents: 610
diff changeset
   560
            return new_row
2b9bd5dcf8d2 Adding support for using keyboard to edit cfile interface variables displayed in Grid
laurent
parents: 610
diff changeset
   561
        setattr(self.VariablesGrid, "_MoveRow", _MoveVariable)
2b9bd5dcf8d2 Adding support for using keyboard to edit cfile interface variables displayed in Grid
laurent
parents: 610
diff changeset
   562
        
145
94855f7b08a9 Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff changeset
   563
        self.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
   564
        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
   565
            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
   566
            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
   567
            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
   568
            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
   569
        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
   570
94855f7b08a9 Improving c_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
    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
   572
        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
   573
        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
   574
        
94855f7b08a9 Improving c_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
    # 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
   576
    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
   577
        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
   578
        self.ParentWindow.RefreshTitle()
587
c6354f7fe26e Restore RefreshFileMenu in CFileEditor
Edouard Tisserant
parents: 586
diff changeset
   579
        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
   580
        self.ParentWindow.RefreshEditMenu()
630
91b2ae63ea3d Including external tools for editing plugin informations into Beremiz window
laurent
parents: 626
diff changeset
   581
        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
   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
    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
   584
        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
   585
        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
   586
        self.VariablesGrid.RefreshButtons()
2b9bd5dcf8d2 Adding support for using keyboard to edit cfile interface variables displayed in Grid
laurent
parents: 610
diff changeset
   587
    
630
91b2ae63ea3d Including external tools for editing plugin informations into Beremiz window
laurent
parents: 626
diff changeset
   588
    def DoGetBestSize(self):
91b2ae63ea3d Including external tools for editing plugin informations into Beremiz window
laurent
parents: 626
diff changeset
   589
        return self.ParentWindow.GetPanelBestSize()
91b2ae63ea3d Including external tools for editing plugin informations into Beremiz window
laurent
parents: 626
diff changeset
   590
    
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
   591
    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
   592
        self.RefreshModel()
656
c1792dfc8c7e Fixing bug integrated plugin editors not closed when removing corresponding plugin
laurent
parents: 653
diff changeset
   593
        wx.CallAfter(self.RefreshView)
145
94855f7b08a9 Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff changeset
   594
        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
   595
94855f7b08a9 Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff changeset
   596
    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
   597
        row, col = event.GetRow(), event.GetCol() 
801
435e49e80832 Update list of messages to be translated for internationalization and french translations
laurent
parents: 782
diff changeset
   598
        if self.Table.GetColLabelValue(col, False) == "Type":
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
   599
            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
   600
            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
   601
            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
   602
                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
   603
                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
   604
                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
   605
            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
   606
            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
   607
            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
   608
                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
   609
                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
   610
                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
   611
            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
   612
            rect = self.VariablesGrid.BlockToDeviceRect((row, col), (row, col))
708
6ec28dc375cf Fixing menu toolbar icons on Windows
laurent
parents: 675
diff changeset
   613
            
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
   614
            self.VariablesGrid.PopupMenuXY(type_menu, rect.x + rect.width, rect.y + self.VariablesGrid.GetColLabelSize())
708
6ec28dc375cf Fixing menu toolbar icons on Windows
laurent
parents: 675
diff changeset
   615
            type_menu.Destroy()
145
94855f7b08a9 Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff changeset
   616
            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
   617
        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
   618
            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
   619
94855f7b08a9 Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff changeset
   620
    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
   621
        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
   622
            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
   623
            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
   624
            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
   625
            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
   626
            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
   627
            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
   628
        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
   629
94855f7b08a9 Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff changeset
   630
    def 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
   631
        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
   632
            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
   633
            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
   634
            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
   635
                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
   636
                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
   637
                    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
   638
                        num += 1
603
e1ef99c609eb added memory location support to C file pluguin
Edouard Tisserant
parents: 587
diff changeset
   639
            elif self.Table.GetValueByName(row, "Class") == "memory":
e1ef99c609eb added memory location support to C file pluguin
Edouard Tisserant
parents: 587
diff changeset
   640
                dir = "%M"
e1ef99c609eb added memory location support to C file pluguin
Edouard Tisserant
parents: 587
diff changeset
   641
                for i in xrange(row):
e1ef99c609eb added memory location support to C file pluguin
Edouard Tisserant
parents: 587
diff changeset
   642
                    if self.Table.GetValueByName(i, "Class") == "memory":
e1ef99c609eb added memory location support to C file pluguin
Edouard Tisserant
parents: 587
diff changeset
   643
                        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
   644
            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
   645
                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
   646
                for i in xrange(row):
161
faad68924b53 Bug on output variable location generation fixed
lbessard
parents: 145
diff changeset
   647
                    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
   648
                        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
   649
            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
   650
            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
   651
            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
   652
            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
   653
            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
   654
            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
   655
            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
   656
            dragSource.DoDragDrop()
874
8b24e9312f18 Fix bug when Drag'n Dropping located variables on Windows
Laurent Bessard
parents: 848
diff changeset
   657
            return
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
   658
        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
   659
    
94855f7b08a9 Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff changeset
   660
94855f7b08a9 Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff changeset
   661
#-------------------------------------------------------------------------------
94855f7b08a9 Improving c_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
#                          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
   663
#-------------------------------------------------------------------------------
94855f7b08a9 Improving c_ext plugin by adding an XML file format for saving C files and an graphical interface for editing this file
lbessard
parents:
diff changeset
   664
630
91b2ae63ea3d Including external tools for editing plugin informations into Beremiz window
laurent
parents: 626
diff changeset
   665
CFILE_PARTS = [
91b2ae63ea3d Including external tools for editing plugin informations into Beremiz window
laurent
parents: 626
diff changeset
   666
    ("Includes", CppEditor), 
91b2ae63ea3d Including external tools for editing plugin informations into Beremiz window
laurent
parents: 626
diff changeset
   667
    ("Variables", VariablesEditor), 
91b2ae63ea3d Including external tools for editing plugin informations into Beremiz window
laurent
parents: 626
diff changeset
   668
    ("Globals", CppEditor), 
91b2ae63ea3d Including external tools for editing plugin informations into Beremiz window
laurent
parents: 626
diff changeset
   669
    ("Init", CppEditor), 
91b2ae63ea3d Including external tools for editing plugin informations into Beremiz window
laurent
parents: 626
diff changeset
   670
    ("CleanUp", CppEditor), 
91b2ae63ea3d Including external tools for editing plugin informations into Beremiz window
laurent
parents: 626
diff changeset
   671
    ("Retrieve", CppEditor), 
91b2ae63ea3d Including external tools for editing plugin informations into Beremiz window
laurent
parents: 626
diff changeset
   672
    ("Publish", CppEditor),
91b2ae63ea3d Including external tools for editing plugin informations into Beremiz window
laurent
parents: 626
diff changeset
   673
]
91b2ae63ea3d Including external tools for editing plugin informations into Beremiz window
laurent
parents: 626
diff changeset
   674
91b2ae63ea3d Including external tools for editing plugin informations into Beremiz window
laurent
parents: 626
diff changeset
   675
class FoldPanelCaption(wx.lib.buttons.GenBitmapTextToggleButton):
91b2ae63ea3d Including external tools for editing plugin informations into Beremiz window
laurent
parents: 626
diff changeset
   676
    
91b2ae63ea3d Including external tools for editing plugin informations into Beremiz window
laurent
parents: 626
diff changeset
   677
    def GetBackgroundBrush(self, dc):
91b2ae63ea3d Including external tools for editing plugin informations into Beremiz window
laurent
parents: 626
diff changeset
   678
        colBg = self.GetBackgroundColour()
91b2ae63ea3d Including external tools for editing plugin informations into Beremiz window
laurent
parents: 626
diff changeset
   679
        brush = wx.Brush(colBg, wx.SOLID)
91b2ae63ea3d Including external tools for editing plugin informations into Beremiz window
laurent
parents: 626
diff changeset
   680
        if self.style & wx.BORDER_NONE:
91b2ae63ea3d Including external tools for editing plugin informations into Beremiz window
laurent
parents: 626
diff changeset
   681
            myAttr = self.GetDefaultAttributes()
91b2ae63ea3d Including external tools for editing plugin informations into Beremiz window
laurent
parents: 626
diff changeset
   682
            parAttr = self.GetParent().GetDefaultAttributes()
91b2ae63ea3d Including external tools for editing plugin informations into Beremiz window
laurent
parents: 626
diff changeset
   683
            myDef = colBg == myAttr.colBg
91b2ae63ea3d Including external tools for editing plugin informations into Beremiz window
laurent
parents: 626
diff changeset
   684
            parDef = self.GetParent().GetBackgroundColour() == parAttr.colBg
91b2ae63ea3d Including external tools for editing plugin informations into Beremiz window
laurent
parents: 626
diff changeset
   685
            if myDef and parDef:
91b2ae63ea3d Including external tools for editing plugin informations into Beremiz window
laurent
parents: 626
diff changeset
   686
                if wx.Platform == "__WXMAC__":
91b2ae63ea3d Including external tools for editing plugin informations into Beremiz window
laurent
parents: 626
diff changeset
   687
                    brush.MacSetTheme(1) # 1 == kThemeBrushDialogBackgroundActive
91b2ae63ea3d Including external tools for editing plugin informations into Beremiz window
laurent
parents: 626
diff changeset
   688
                elif wx.Platform == "__WXMSW__":
91b2ae63ea3d Including external tools for editing plugin informations into Beremiz window
laurent
parents: 626
diff changeset
   689
                    if self.DoEraseBackground(dc):
91b2ae63ea3d Including external tools for editing plugin informations into Beremiz window
laurent
parents: 626
diff changeset
   690
                        brush = None
91b2ae63ea3d Including external tools for editing plugin informations into Beremiz window
laurent
parents: 626
diff changeset
   691
            elif myDef and not parDef:
91b2ae63ea3d Including external tools for editing plugin informations into Beremiz window
laurent
parents: 626
diff changeset
   692
                colBg = self.GetParent().GetBackgroundColour()
91b2ae63ea3d Including external tools for editing plugin informations into Beremiz window
laurent
parents: 626
diff changeset
   693
                brush = wx.Brush(colBg, wx.SOLID)
91b2ae63ea3d Including external tools for editing plugin informations into Beremiz window
laurent
parents: 626
diff changeset
   694
        return brush
91b2ae63ea3d Including external tools for editing plugin informations into Beremiz window
laurent
parents: 626
diff changeset
   695
    
91b2ae63ea3d Including external tools for editing plugin informations into Beremiz window
laurent
parents: 626
diff changeset
   696
    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
   697
        bmp = self.bmpLabel
91b2ae63ea3d Including external tools for editing plugin informations into Beremiz window
laurent
parents: 626
diff changeset
   698
        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
   699
            if self.bmpDisabled and not self.IsEnabled():
91b2ae63ea3d Including external tools for editing plugin informations into Beremiz window
laurent
parents: 626
diff changeset
   700
                bmp = self.bmpDisabled
91b2ae63ea3d Including external tools for editing plugin informations into Beremiz window
laurent
parents: 626
diff changeset
   701
            if self.bmpFocus and self.hasFocus:
91b2ae63ea3d Including external tools for editing plugin informations into Beremiz window
laurent
parents: 626
diff changeset
   702
                bmp = self.bmpFocus
91b2ae63ea3d Including external tools for editing plugin informations into Beremiz window
laurent
parents: 626
diff changeset
   703
            if self.bmpSelected and not self.up:
91b2ae63ea3d Including external tools for editing plugin informations into Beremiz window
laurent
parents: 626
diff changeset
   704
                bmp = self.bmpSelected
91b2ae63ea3d Including external tools for editing plugin informations into Beremiz window
laurent
parents: 626
diff changeset
   705
            bw,bh = bmp.GetWidth(), bmp.GetHeight()
91b2ae63ea3d Including external tools for editing plugin informations into Beremiz window
laurent
parents: 626
diff changeset
   706
            hasMask = bmp.GetMask() is not None
91b2ae63ea3d Including external tools for editing plugin informations into Beremiz window
laurent
parents: 626
diff changeset
   707
        else:
91b2ae63ea3d Including external tools for editing plugin informations into Beremiz window
laurent
parents: 626
diff changeset
   708
            bw = bh = 0     # no bitmap -> size is zero
91b2ae63ea3d Including external tools for editing plugin informations into Beremiz window
laurent
parents: 626
diff changeset
   709
        
91b2ae63ea3d Including external tools for editing plugin informations into Beremiz window
laurent
parents: 626
diff changeset
   710
        dc.SetFont(self.GetFont())
91b2ae63ea3d Including external tools for editing plugin informations into Beremiz window
laurent
parents: 626
diff changeset
   711
        if self.IsEnabled():
91b2ae63ea3d Including external tools for editing plugin informations into Beremiz window
laurent
parents: 626
diff changeset
   712
            dc.SetTextForeground(self.GetForegroundColour())
91b2ae63ea3d Including external tools for editing plugin informations into Beremiz window
laurent
parents: 626
diff changeset
   713
        else:
91b2ae63ea3d Including external tools for editing plugin informations into Beremiz window
laurent
parents: 626
diff changeset
   714
            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
   715
91b2ae63ea3d Including external tools for editing plugin informations into Beremiz window
laurent
parents: 626
diff changeset
   716
        label = self.GetLabel()
91b2ae63ea3d Including external tools for editing plugin informations into Beremiz window
laurent
parents: 626
diff changeset
   717
        tw, th = dc.GetTextExtent(label)        # size of text
91b2ae63ea3d Including external tools for editing plugin informations into Beremiz window
laurent
parents: 626
diff changeset
   718
        
91b2ae63ea3d Including external tools for editing plugin informations into Beremiz window
laurent
parents: 626
diff changeset
   719
        if bmp is not None:
91b2ae63ea3d Including external tools for editing plugin informations into Beremiz window
laurent
parents: 626
diff changeset
   720
            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
   721
        
91b2ae63ea3d Including external tools for editing plugin informations into Beremiz window
laurent
parents: 626
diff changeset
   722
        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
   723
91b2ae63ea3d Including external tools for editing plugin informations into Beremiz window
laurent
parents: 626
diff changeset
   724
        dc.SetPen(wx.Pen(self.GetForegroundColour()))
91b2ae63ea3d Including external tools for editing plugin informations into Beremiz window
laurent
parents: 626
diff changeset
   725
        dc.SetBrush(wx.TRANSPARENT_BRUSH)
91b2ae63ea3d Including external tools for editing plugin informations into Beremiz window
laurent
parents: 626
diff changeset
   726
        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
   727
738
413946c04c87 refactoring
laurent
parents: 734
diff changeset
   728
class CFileEditor(ConfTreeNodeEditor):
413946c04c87 refactoring
laurent
parents: 734
diff changeset
   729
    
413946c04c87 refactoring
laurent
parents: 734
diff changeset
   730
    def _init_ConfNodeEditor(self, prnt):
848
fe9504c4104e Replacing text buttons by bitmap buttons for variable grid in CFileEditor
laurent
parents: 814
diff changeset
   731
        self.ConfNodeEditor = wx.Panel(prnt, style=wx.TAB_TRAVERSAL)
630
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
        self.Panels = {}
91b2ae63ea3d Including external tools for editing plugin informations into Beremiz window
laurent
parents: 626
diff changeset
   734
        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
   735
        self.MainSizer.AddGrowableCol(0)
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
        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
   738
            button_id = wx.NewId()
91b2ae63ea3d Including external tools for editing plugin informations into Beremiz window
laurent
parents: 626
diff changeset
   739
            button = FoldPanelCaption(id=button_id, name='FoldPanelCaption_%s' % name, 
782
6f0e10085df9 Adding support for file explorer for project files
laurent
parents: 751
diff changeset
   740
                  label=name, bitmap=GetBitmap("CollapsedIconData"), 
738
413946c04c87 refactoring
laurent
parents: 734
diff changeset
   741
                  parent=self.ConfNodeEditor, pos=wx.Point(0, 0),
630
91b2ae63ea3d Including external tools for editing plugin informations into Beremiz window
laurent
parents: 626
diff changeset
   742
                  size=wx.Size(0, 20), style=wx.NO_BORDER|wx.ALIGN_LEFT)
782
6f0e10085df9 Adding support for file explorer for project files
laurent
parents: 751
diff changeset
   743
            button.SetBitmapSelected(GetBitmap("ExpandedIconData"))
630
91b2ae63ea3d Including external tools for editing plugin informations into Beremiz window
laurent
parents: 626
diff changeset
   744
            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
   745
            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
   746
            
91b2ae63ea3d Including external tools for editing plugin informations into Beremiz window
laurent
parents: 626
diff changeset
   747
            if panel_class == VariablesEditor:
738
413946c04c87 refactoring
laurent
parents: 734
diff changeset
   748
                panel = VariablesEditor(self.ConfNodeEditor, self.ParentWindow, self.Controler)
413946c04c87 refactoring
laurent
parents: 734
diff changeset
   749
            else:
413946c04c87 refactoring
laurent
parents: 734
diff changeset
   750
                panel = panel_class(self.ConfNodeEditor, name, self.ParentWindow, self.Controler)
630
91b2ae63ea3d Including external tools for editing plugin informations into Beremiz window
laurent
parents: 626
diff changeset
   751
            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
   752
            panel.Hide()
91b2ae63ea3d Including external tools for editing plugin informations into Beremiz window
laurent
parents: 626
diff changeset
   753
            
91b2ae63ea3d Including external tools for editing plugin informations into Beremiz window
laurent
parents: 626
diff changeset
   754
            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
   755
        
738
413946c04c87 refactoring
laurent
parents: 734
diff changeset
   756
        self.Spacer = wx.Panel(self.ConfNodeEditor, -1)
630
91b2ae63ea3d Including external tools for editing plugin informations into Beremiz window
laurent
parents: 626
diff changeset
   757
        self.SpacerExpanded = True
91b2ae63ea3d Including external tools for editing plugin informations into Beremiz window
laurent
parents: 626
diff changeset
   758
        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
   759
        
91b2ae63ea3d Including external tools for editing plugin informations into Beremiz window
laurent
parents: 626
diff changeset
   760
        self.MainSizer.AddGrowableRow(2 * len(CFILE_PARTS))
91b2ae63ea3d Including external tools for editing plugin informations into Beremiz window
laurent
parents: 626
diff changeset
   761
        
738
413946c04c87 refactoring
laurent
parents: 734
diff changeset
   762
        self.ConfNodeEditor.SetSizer(self.MainSizer)
413946c04c87 refactoring
laurent
parents: 734
diff changeset
   763
    
630
91b2ae63ea3d Including external tools for editing plugin informations into Beremiz window
laurent
parents: 626
diff changeset
   764
    def __init__(self, parent, controler, window):
743
4645a3a398ad Fix bugs with ConfigTreeNode
laurent
parents: 738
diff changeset
   765
        ConfTreeNodeEditor.__init__(self, parent, controler, window)
630
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 GetBufferState(self):
91b2ae63ea3d Including external tools for editing plugin informations into Beremiz window
laurent
parents: 626
diff changeset
   768
        return self.Controler.GetBufferState()
91b2ae63ea3d Including external tools for editing plugin informations into Beremiz window
laurent
parents: 626
diff changeset
   769
        
91b2ae63ea3d Including external tools for editing plugin informations into Beremiz window
laurent
parents: 626
diff changeset
   770
    def Undo(self):
91b2ae63ea3d Including external tools for editing plugin informations into Beremiz window
laurent
parents: 626
diff changeset
   771
        self.Controler.LoadPrevious()
91b2ae63ea3d Including external tools for editing plugin informations into Beremiz window
laurent
parents: 626
diff changeset
   772
        self.RefreshView()
91b2ae63ea3d Including external tools for editing plugin informations into Beremiz window
laurent
parents: 626
diff changeset
   773
            
91b2ae63ea3d Including external tools for editing plugin informations into Beremiz window
laurent
parents: 626
diff changeset
   774
    def Redo(self):
91b2ae63ea3d Including external tools for editing plugin informations into Beremiz window
laurent
parents: 626
diff changeset
   775
        self.Controler.LoadNext()
91b2ae63ea3d Including external tools for editing plugin informations into Beremiz window
laurent
parents: 626
diff changeset
   776
        self.RefreshView()
91b2ae63ea3d Including external tools for editing plugin informations into Beremiz window
laurent
parents: 626
diff changeset
   777
    
91b2ae63ea3d Including external tools for editing plugin informations into Beremiz window
laurent
parents: 626
diff changeset
   778
    def RefreshView(self):
751
a8dace95f965 Fixing bug on ConfNodeEditors refresh
laurent
parents: 744
diff changeset
   779
        ConfTreeNodeEditor.RefreshView(self)
a8dace95f965 Fixing bug on ConfNodeEditors refresh
laurent
parents: 744
diff changeset
   780
        
630
91b2ae63ea3d Including external tools for editing plugin informations into Beremiz window
laurent
parents: 626
diff changeset
   781
        for infos in self.Panels.itervalues():
91b2ae63ea3d Including external tools for editing plugin informations into Beremiz window
laurent
parents: 626
diff changeset
   782
            infos["panel"].RefreshView()
91b2ae63ea3d Including external tools for editing plugin informations into Beremiz window
laurent
parents: 626
diff changeset
   783
91b2ae63ea3d Including external tools for editing plugin informations into Beremiz window
laurent
parents: 626
diff changeset
   784
    def GenPanelButtonCallback(self, name):
91b2ae63ea3d Including external tools for editing plugin informations into Beremiz window
laurent
parents: 626
diff changeset
   785
        def PanelButtonCallback(event):
91b2ae63ea3d Including external tools for editing plugin informations into Beremiz window
laurent
parents: 626
diff changeset
   786
            self.TogglePanel(name)
91b2ae63ea3d Including external tools for editing plugin informations into Beremiz window
laurent
parents: 626
diff changeset
   787
        return PanelButtonCallback
91b2ae63ea3d Including external tools for editing plugin informations into Beremiz window
laurent
parents: 626
diff changeset
   788
91b2ae63ea3d Including external tools for editing plugin informations into Beremiz window
laurent
parents: 626
diff changeset
   789
    def ExpandPanel(self, name):
91b2ae63ea3d Including external tools for editing plugin informations into Beremiz window
laurent
parents: 626
diff changeset
   790
        infos = self.Panels.get(name, None)
91b2ae63ea3d Including external tools for editing plugin informations into Beremiz window
laurent
parents: 626
diff changeset
   791
        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
   792
            infos["expanded"] = True
91b2ae63ea3d Including external tools for editing plugin informations into Beremiz window
laurent
parents: 626
diff changeset
   793
            infos["button"].SetToggle(True)
91b2ae63ea3d Including external tools for editing plugin informations into Beremiz window
laurent
parents: 626
diff changeset
   794
            infos["panel"].Show()
91b2ae63ea3d Including external tools for editing plugin informations into Beremiz window
laurent
parents: 626
diff changeset
   795
            self.MainSizer.AddGrowableRow(infos["row"])
91b2ae63ea3d Including external tools for editing plugin informations into Beremiz window
laurent
parents: 626
diff changeset
   796
        
91b2ae63ea3d Including external tools for editing plugin informations into Beremiz window
laurent
parents: 626
diff changeset
   797
            self.RefreshSizerLayout()
91b2ae63ea3d Including external tools for editing plugin informations into Beremiz window
laurent
parents: 626
diff changeset
   798
    
91b2ae63ea3d Including external tools for editing plugin informations into Beremiz window
laurent
parents: 626
diff changeset
   799
    def CollapsePanel(self, name):
91b2ae63ea3d Including external tools for editing plugin informations into Beremiz window
laurent
parents: 626
diff changeset
   800
        infos = self.Panels.get(name, None)
91b2ae63ea3d Including external tools for editing plugin informations into Beremiz window
laurent
parents: 626
diff changeset
   801
        if infos is not None and infos["expanded"]:
91b2ae63ea3d Including external tools for editing plugin informations into Beremiz window
laurent
parents: 626
diff changeset
   802
            infos["expanded"] = False
91b2ae63ea3d Including external tools for editing plugin informations into Beremiz window
laurent
parents: 626
diff changeset
   803
            infos["button"].SetToggle(False)
91b2ae63ea3d Including external tools for editing plugin informations into Beremiz window
laurent
parents: 626
diff changeset
   804
            infos["panel"].Hide()
91b2ae63ea3d Including external tools for editing plugin informations into Beremiz window
laurent
parents: 626
diff changeset
   805
            self.MainSizer.RemoveGrowableRow(infos["row"])
91b2ae63ea3d Including external tools for editing plugin informations into Beremiz window
laurent
parents: 626
diff changeset
   806
        
91b2ae63ea3d Including external tools for editing plugin informations into Beremiz window
laurent
parents: 626
diff changeset
   807
            self.RefreshSizerLayout()
91b2ae63ea3d Including external tools for editing plugin informations into Beremiz window
laurent
parents: 626
diff changeset
   808
        
91b2ae63ea3d Including external tools for editing plugin informations into Beremiz window
laurent
parents: 626
diff changeset
   809
    def TogglePanel(self, name):
91b2ae63ea3d Including external tools for editing plugin informations into Beremiz window
laurent
parents: 626
diff changeset
   810
        infos = self.Panels.get(name, None)
91b2ae63ea3d Including external tools for editing plugin informations into Beremiz window
laurent
parents: 626
diff changeset
   811
        if infos is not None:
91b2ae63ea3d Including external tools for editing plugin informations into Beremiz window
laurent
parents: 626
diff changeset
   812
            infos["expanded"] = not infos["expanded"]
91b2ae63ea3d Including external tools for editing plugin informations into Beremiz window
laurent
parents: 626
diff changeset
   813
            infos["button"].SetToggle(infos["expanded"])
91b2ae63ea3d Including external tools for editing plugin informations into Beremiz window
laurent
parents: 626
diff changeset
   814
            if infos["expanded"]:
91b2ae63ea3d Including external tools for editing plugin informations into Beremiz window
laurent
parents: 626
diff changeset
   815
                infos["panel"].Show()
91b2ae63ea3d Including external tools for editing plugin informations into Beremiz window
laurent
parents: 626
diff changeset
   816
                self.MainSizer.AddGrowableRow(infos["row"])
164
072e81cc65fe Bug on wx2.6 with PartsOpened fixed
lbessard
parents: 161
diff changeset
   817
            else:
630
91b2ae63ea3d Including external tools for editing plugin informations into Beremiz window
laurent
parents: 626
diff changeset
   818
                infos["panel"].Hide()
91b2ae63ea3d Including external tools for editing plugin informations into Beremiz window
laurent
parents: 626
diff changeset
   819
                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
   820
            
630
91b2ae63ea3d Including external tools for editing plugin informations into Beremiz window
laurent
parents: 626
diff changeset
   821
            self.RefreshSizerLayout()
91b2ae63ea3d Including external tools for editing plugin informations into Beremiz window
laurent
parents: 626
diff changeset
   822
    
91b2ae63ea3d Including external tools for editing plugin informations into Beremiz window
laurent
parents: 626
diff changeset
   823
    def RefreshSizerLayout(self):
91b2ae63ea3d Including external tools for editing plugin informations into Beremiz window
laurent
parents: 626
diff changeset
   824
        expand_spacer = True
91b2ae63ea3d Including external tools for editing plugin informations into Beremiz window
laurent
parents: 626
diff changeset
   825
        for infos in self.Panels.itervalues():
91b2ae63ea3d Including external tools for editing plugin informations into Beremiz window
laurent
parents: 626
diff changeset
   826
            expand_spacer = expand_spacer and not infos["expanded"]
91b2ae63ea3d Including external tools for editing plugin informations into Beremiz window
laurent
parents: 626
diff changeset
   827
        
91b2ae63ea3d Including external tools for editing plugin informations into Beremiz window
laurent
parents: 626
diff changeset
   828
        if self.SpacerExpanded != expand_spacer:
91b2ae63ea3d Including external tools for editing plugin informations into Beremiz window
laurent
parents: 626
diff changeset
   829
            self.SpacerExpanded = expand_spacer
91b2ae63ea3d Including external tools for editing plugin informations into Beremiz window
laurent
parents: 626
diff changeset
   830
            if expand_spacer:
91b2ae63ea3d Including external tools for editing plugin informations into Beremiz window
laurent
parents: 626
diff changeset
   831
                self.Spacer.Show()
91b2ae63ea3d Including external tools for editing plugin informations into Beremiz window
laurent
parents: 626
diff changeset
   832
                self.MainSizer.AddGrowableRow(2 * len(CFILE_PARTS))
91b2ae63ea3d Including external tools for editing plugin informations into Beremiz window
laurent
parents: 626
diff changeset
   833
            else:
91b2ae63ea3d Including external tools for editing plugin informations into Beremiz window
laurent
parents: 626
diff changeset
   834
                self.Spacer.Hide()
91b2ae63ea3d Including external tools for editing plugin informations into Beremiz window
laurent
parents: 626
diff changeset
   835
                self.MainSizer.RemoveGrowableRow(2 * len(CFILE_PARTS))
91b2ae63ea3d Including external tools for editing plugin informations into Beremiz window
laurent
parents: 626
diff changeset
   836
        
91b2ae63ea3d Including external tools for editing plugin informations into Beremiz window
laurent
parents: 626
diff changeset
   837
        self.MainSizer.Layout()
213
d8dc1e51c3bf Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents: 185
diff changeset
   838