File: genericEditor.ec

package info (click to toggle)
ecere-sdk 0.44.15-1
  • links: PTS
  • area: main
  • in suites: sid, stretch
  • size: 97,712 kB
  • ctags: 54,695
  • sloc: ansic: 593,042; makefile: 12,250; yacc: 4,955; lex: 707; objc: 259; python: 252; xml: 102
file content (74 lines) | stat: -rw-r--r-- 1,724 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
import "EDA"

class GenericEditor : Window
{
   text = " ";
   tabCycle = true;
   size = { 800, 600 };
   fullRender = true;

   Array<FieldDataBox> dataBoxes { };
   Array<Label> labels { };

   void Clear()
   {
      for(l : labels)
         delete l;
      labels.Free();

      for(d : dataBoxes)
         delete d;
      dataBoxes.Free();
   }

   public property Table table
   {
      set
      {
         Field f;
         int y = 8;

         Clear();

         editor.table = value;
         if(!list.fldName && value)
            list.fldName = value.FindField("Name");
         list.table = value;
         for(f = value ? value.firstField : null; f; f = f.next)
         {
            if(strcmpi(f.name, "ID"))
            {
               int h = 20;
               FieldDataBox box { editor = editor, field = f, text = f.name, size = { h = h }, anchor = { left = 20, top = y + 16, right = 20 } };
               Label label { editor.editArea, position = { 20, y }, labeledWindow = box };
               if(eClass_IsDerived(f.type, class(DataList)) || eClass_IsDerived(f.type, class(IdList)) || eClass_IsDerived(f.type, class(MultiLineString)))
               {
                  h = 70;
                  box.size.h = h;
               }
               incref box;
               incref label;
               dataBoxes.Add(box);
               labels.Add(label);
               y += 20 + h;
            }
         }
      }
   }

   ~GenericEditor()
   {
      Clear();
   }

   ListSection list
   {
      this, editor = editor,
      anchor = { left = 0, top = 0, bottom = 0, right = 0.5 }
   };
   EditSection editor
   {
      this,
      anchor = { left = 0.5, top = 0, bottom = 0, right = 0 }
   };
}