ide;debugger; (#1004) fixed remaining crash on closed linked code editor modified...
[sdk] / extras / genericEditor.ec
1 import "EDA"
2
3 class GenericEditor : Window
4 {
5    text = " ";
6    tabCycle = true;
7    size = { 800, 600 };
8
9    Array<FieldDataBox> dataBoxes { };
10    Array<Label> labels { };
11
12    void Clear()
13    {
14       for(l : labels)
15          delete l;
16       labels.Free();
17
18       for(d : dataBoxes)
19          delete d;
20       dataBoxes.Free();
21    }
22
23    public property Table table
24    {
25       set
26       {
27          Field f;
28          int y = 8;
29
30          Clear();
31
32          editor.table = value;
33          if(!list.fldName && value)
34             list.fldName = value.FindField("Name");
35          list.table = value;
36          for(f = value ? value.firstField : null; f; f = f.next)
37          {
38             if(strcmpi(f.name, "ID"))
39             {
40                FieldDataBox box { editor = editor, field = f, text = f.name, size = { 200, 20 }, position = { 20, y + 16} };
41                Label label { editor.editArea, position = { 20, y }, labeledWindow = box };
42                incref box;
43                incref label;
44                dataBoxes.Add(box);
45                labels.Add(label);
46                y += 40;
47             }
48          }
49       }
50    }
51
52    ~GenericEditor()
53    {
54       Clear();
55    }
56
57    ListSection list
58    {
59       this, editor = editor,
60       anchor = { left = 0, top = 0, bottom = 0, right = 0.5 }
61    };
62    EditSection editor
63    {
64       this,
65       anchor = { left = 0.5, top = 0, bottom = 0, right = 0 }
66    };
67 }