eda: Using 'Id' rather than uint or uint64
[sdk] / eda / libeda / src / gui.ec
index d49c420..04a9216 100644 (file)
@@ -5,18 +5,19 @@ define shadowS = 4;
 
 default:
 extern int __ecereVMethodID_class_OnFree;
+extern int __ecereVMethodID_class_OnGetString;
 private:
 
-char * defaultNameField = "Name";
-char * defaultIdField = "Id";
-char * defaultActiveField = "Active";
+const char * defaultNameField = "Name";
+const char * defaultIdField = "Id";
+const char * defaultActiveField = "Active";
 
-public void SetDefaultIdField(char * value) { defaultIdField = value; }
-public void SetDefaultNameField(char * value) { defaultNameField = value; }
+public void SetDefaultIdField(const char * value) { defaultIdField = value; }
+public void SetDefaultNameField(const char * value) { defaultNameField = value; }
 
 public class ButtonStyle : Button
 {
-   font = { "Arial", 10, bold = true };
+   font = { $"Arial", 10, bold = true };
    creationActivation = doNothing;
 }
 
@@ -26,7 +27,8 @@ public class Group : Window
    tabCycle = true;
    //inactive = true; // TOFIX causes problems...
 
-   public Label title { this, font = { "Arial", 10, bold = true }, position = { 16, 2 } };
+public:
+   Label title { this, font = { $"Arial", 10, bold = true }, position = { 16, 2 } };
 
    bool OnCreate()
    {
@@ -55,20 +57,22 @@ public class CheckBool : bool
 {
    Window OnEdit(DataBox dataBox, DataBox obsolete, int x, int y, int w, int h, void * userData)
    {
-      if(this || !this) {     // FIXME
-      Button button = dataBox.keepEditor ? (Button)obsolete : null;
+      Button button = dataBox.keepEditor ? (Button)dataBox.editor : null;
       if(!button)
       {
          button = Button
          {
             dataBox, borderStyle = 0, text = dataBox.text, anchor = { 0, 0, 0, 0 },
             // size = { 100, 22 };
-            modifyVirtualArea = false, isCheckbox = true;            
+            modifyVirtualArea = false, isCheckbox = true;
 
             bool DataBox::NotifyClicked(Button control, int x, int y, Modifiers mods)
             {
                bool checked = control.checked;
-               SetData(&checked, false);
+               if(readOnly)
+                  control.checked = !checked;
+               else
+                  SetData(&checked, false);
                return true;
             }
          };
@@ -76,9 +80,34 @@ public class CheckBool : bool
       button.checked = this;
       button.Create();
       return button;
+   }
+}
+
+String GetNameString(Row r, Field nameField)
+{
+   String s = null;
+   if(nameField.type != class(String) && nameField.type != class(char *))
+   {
+      char tempString[4096];
+      Class type = nameField.type;
+      int64 data = 0;
+      if(type.type == structClass)
+         data = (int64)(intptr)new0 byte[type.structSize];
+      ((bool (*)())(void *)r.GetData)(r, nameField, type, (type.type == structClass) ? (void *)(intptr)data : &data);
+      if(type.type == systemClass || type.type == enumClass || type.type == bitClass)
+         s = CopyString(((char *(*)(void *, void *, char *, void *, bool *))(void *)type._vTbl[__ecereVMethodID_class_OnGetString])(type, &data, tempString, null, null));
+      else
+         s = CopyString(((char *(*)(void *, void *, char *, void *, bool *))(void *)type._vTbl[__ecereVMethodID_class_OnGetString])(type, (void *)(intptr)data, tempString, null, null));
+      ((void (*)(void *, void *))(void *)type._vTbl[__ecereVMethodID_class_OnFree])(type, (void *)(intptr)data);
+      if(type.type == structClass)
+      {
+         void * _data = (void *)(intptr)data;
+         delete _data;
       }
-      return null;
    }
+   else
+      r.GetData(nameField, s);
+   return s;
 }
 
 public class TableDropBox : DropBox
@@ -86,14 +115,15 @@ public class TableDropBox : DropBox
    anchor = { left = 130, top = 180, right = shadowS + sgs * 2 };
    borderStyle = deep;
 
-   public uint filter;
-   public bool filtered;
-   public Field nameField;
-   public uint exclusion;
-   public Table table;
-   public Field filterField;
+public:
+   Id filter;
+   bool filtered;
+   Field nameField;
+   Id exclusion;
+   Table table;
+   Field filterField;
 
-   public property uint filter
+   property Id filter
    {
       set
       {
@@ -102,11 +132,11 @@ public class TableDropBox : DropBox
       }
       get { return filter; }
    }
-   public property Field nameField { set { nameField = value; } }
-   public property uint exclusion { set { exclusion = value; } }
-   public property Table table { set { table = value; if(!nameField && value) nameField = value.FindField(defaultNameField); } }
+   property Field nameField { set { nameField = value; } }
+   property Id exclusion { set { exclusion = value; } }
+   property Table table { set { table = value; if(!nameField && value) nameField = value.FindField(defaultNameField); } }
 
-   public virtual void Refill()
+   virtual void Refill()
    {
       Clear();
       if(table)
@@ -121,7 +151,7 @@ public class TableDropBox : DropBox
                {
                   FieldIndex indexedFields[1];
                   // Table tbl = table.db.OpenTable(table.name, { tableRows });
-                  char * name = table.name;
+                  const char * name = table.name;
                   Database db = table.db;
                   Table tbl = db.OpenTable(name, { tableRows });
                   if(tbl)
@@ -132,7 +162,7 @@ public class TableDropBox : DropBox
                      tbl.GenerateIndex(1, indexedFields, false);
 
                      r = Row { tbl };
-                     
+
                      for(r.Find(filterField, middle, nil, filter); !r.nil; r.Next()) //while(r.Next())
                      {
                         Id id;
@@ -143,8 +173,7 @@ public class TableDropBox : DropBox
                            break;
                         if(!exclusion || id != exclusion)
                         {
-                           String s;
-                           r.GetData(nameField, s);
+                           String s = GetNameString(r, nameField);
                            AddString(s).tag = id;
                            delete s;
                         }
@@ -161,8 +190,7 @@ public class TableDropBox : DropBox
                      r.GetData(fldId, id);
                      if(idList && idList.Includes(filter) && (!exclusion || !idList.Includes(exclusion)))
                      {
-                        String s;
-                        r.GetData(nameField, s);
+                        String s = GetNameString(r, nameField);
                         AddString(s).tag = id;
                         delete s;
                      }
@@ -178,8 +206,7 @@ public class TableDropBox : DropBox
                   r.GetData(fldId, id);
                   if(id != exclusion)
                   {
-                     String s;
-                     r.GetData(nameField, s);
+                     String s = GetNameString(r, nameField);
                      AddString(s).tag = id;
                      delete s;
                   }
@@ -190,9 +217,8 @@ public class TableDropBox : DropBox
                while(r.Next())
                {
                   Id id;
-                  String s;
+                  String s = GetNameString(r, nameField);
                   r.GetData(fldId, id);
-                  r.GetData(nameField, s);
                   AddString(s).tag = id;
                   delete s;
                }
@@ -203,7 +229,7 @@ public class TableDropBox : DropBox
       Sort(null, 1);
    }
 
-   public property Field filterField { set { filterField = value; } }
+   property Field filterField { set { filterField = value; } }
 
    bool OnKeyHit(Key key, unichar ch)
    {
@@ -214,7 +240,7 @@ public class TableDropBox : DropBox
       }
       else if((SmartKey)key == enter)
          parent.CycleChildren(true, false, false, true);
-      
+
       return DropBox::OnKeyHit(key, ch);
    }
 
@@ -230,16 +256,16 @@ public class TableDropBox : DropBox
       return true;
    }
 
-   public void EditNotifyCharsAdded()
+   void EditNotifyCharsAdded()
    {
       if(!editBox.NotifyUpdate || editBox.NotifyUpdate == EditBox::NotifyUpdate)
          editBox.NotifyUpdate = EditNotifyUpdate;
    }
 
-   public void EditNotifyUpdate(EditBox editBox)
+   void EditNotifyUpdate(EditBox editBox)
    {
       DataRow row;
-      char * contents = editBox.contents;
+      const char * contents = editBox.contents;
       int len = strlen(contents);
       if(len && editBox.charPos == len)
       {
@@ -251,7 +277,7 @@ public class TableDropBox : DropBox
          {
             for(row = firstRow; row; row = row.next)
             {
-               char * string = row.string;
+               const char * string = row.string;
                if(string && SearchString(string, 0, contents, false, false) == string)
                {
                   // SelectRow(row);
@@ -271,29 +297,24 @@ public class DropDataBox : DataBox
    size.h = 24;
    keepEditor = true;
    borderStyle = deep;
-
-   Field nameField;
-   Field filterField;
-   uint exclusion;
-   uint filter;
-   bool filtered;
-   bool showNone;
    showNone = false; //true;
 
-   public property uint filter { set { filtered = true; filter = value; } get { return filter; } }
-   public property bool filtered { set { filtered = value; } }
-   public property uint exclusion { set { exclusion = value; } }
-   public property Field filterField { set { filterField = value; } }
-   public property Field nameField { set { nameField = value; } }
-   public virtual void TableDropBox::RefillFunction();
-   public property bool showNone { set { showNone = value; } }
+public:
+
+   property Id filter { set { filtered = true; filter = value; } get { return filter; } }
+   property bool filtered { set { filtered = value; } }
+   property Id exclusion { set { exclusion = value; } }
+   property Field filterField { set { filterField = value; } }
+   property Field nameField { set { nameField = value; } }
+   virtual void TableDropBox::RefillFunction();
+   property bool showNone { set { showNone = value; } }
 
-   public void Refill()
+   void Refill()
    {
       if(editor)
       {
          TableDropBox dropBox = (TableDropBox) editor;
-         uint id = data ? *(uint *)data : MAXDWORD;
+         Id id = data ? *(Id *)data : MAXDWORD;
          void * notifyChanged = (void *)NotifyChanged;
 
          OnConfigure(dropBox);
@@ -315,10 +336,18 @@ public class DropDataBox : DataBox
          dropBox.filter = filter;
       else
          dropBox.filtered = false;
-      
+
       dropBox.exclusion = exclusion;
       dropBox.showNone = showNone;
    }
+
+private:
+   Field nameField;
+   Field filterField;
+   Id exclusion;
+   Id filter;
+   bool filtered;
+   bool showNone;
 }
 
 public class EditDropDataBox : DropDataBox
@@ -337,16 +366,16 @@ public class FieldDataBox : DataBox
    anchor = { left = 110, right = shadowS + sgs * 2 };
    borderStyle = deep;
 
-   Field field;
-   int64 dataHolder; // THERE SEEMS TO BE A BUG WHEN ACCESSING row ACROSS .so
-   Row row;
+   // TOCHECK: Testing this for GenericEditor performance issue?
+   keepEditor = true;
 
-   public property Row row
+public:
+   property Row row
    {
       set { row = value; }
       get { return row; }
    }
-   public property EditSection editor
+   property EditSection editor
    {
       set
       {
@@ -357,7 +386,7 @@ public class FieldDataBox : DataBox
       }
    };
 
-   public property Field field
+   property Field field
    {
       set
       {
@@ -366,10 +395,10 @@ public class FieldDataBox : DataBox
 
          if(dataHolder)
          {
-            type._vTbl[__ecereVMethodID_class_OnFree](type, dataHolder);
+            ((void (*)(void *, void *))(void *)type._vTbl[__ecereVMethodID_class_OnFree])(type, (void *)(intptr)dataHolder);
             if(type.type == structClass)
             {
-               void * dataPtr = (void *)dataHolder;
+               void * dataPtr = (void *)(intptr)dataHolder;
                delete dataPtr;
             }
             dataHolder = 0;
@@ -382,15 +411,15 @@ public class FieldDataBox : DataBox
 
          if(dataType && dataType.type == structClass)
          {
-            dataHolder = (int64)new0 byte[dataType.structSize];
-            data = (void *)dataHolder;
+            dataHolder = (int64)(intptr)new0 byte[dataType.structSize];
+            data = (void *)(intptr)dataHolder;
          }
          else if(dataType && (dataType.type == noHeadClass || dataType.type == normalClass))
          {
             if(eClass_IsDerived(dataType, class(String)))
-               dataHolder = (int64)CopyString("");
+               dataHolder = (int64)(intptr)CopyString("");
             else
-               dataHolder = (int64)eInstance_New(dataType);
+               dataHolder = (int64)(intptr)eInstance_New(dataType);
             data = (void *)&dataHolder;
          }
          else
@@ -402,30 +431,27 @@ public class FieldDataBox : DataBox
       }
    }
 
-   public void Clear()
+   void Clear()
    {
-      if(visible)
-      {
-         if(data)
-            SetData(null, false);
-
-         if(type && (type.type == noHeadClass || type.type == normalClass))
-         {
-            if(eClass_IsDerived(type, class(String)))
-               dataHolder = (int64)CopyString("");
-            else
-               dataHolder = (int64)eInstance_New(type);
-            data = (void *)&dataHolder;
-         }
+      if(data)
+         SetData(null, false);
 
-         if(created)
-            Refresh();
+      if(type && (type.type == noHeadClass || type.type == normalClass))
+      {
+         if(eClass_IsDerived(type, class(String)))
+            dataHolder = (int64)(intptr)CopyString("");
+         else
+            dataHolder = (int64)(intptr)eInstance_New(type);
+         data = (void *)&dataHolder;
       }
+
+      if(created)
+         Refresh();
    }
 
-   public void Load()
+   void Load()
    {
-      if(visible && field && row)
+      if(field && row)
       {
          SetData(null, false);
          master.modifiedDocument = false;
@@ -435,9 +461,9 @@ public class FieldDataBox : DataBox
          if(!dataHolder && type && (type.type == noHeadClass || type.type == normalClass))
          {
             if(eClass_IsDerived(type, class(String)))
-               dataHolder = (int64)CopyString("");
+               dataHolder = (int64)(intptr)CopyString("");
             else
-               dataHolder = (int64)eInstance_New(type);
+               dataHolder = (int64)(intptr)eInstance_New(type);
             data = (void *)&dataHolder;
          }
 
@@ -446,23 +472,22 @@ public class FieldDataBox : DataBox
       }
    }
 
-   public virtual void Save()
+   virtual void Save()
    {
-      bool result;
-      if(visible && field && row)
+      if(field && row)
       {
          Class type = field.type;
          if(!DataBox::SaveData())
             Refresh();
 
-         ((bool (*)())(void *)Row::SetData)(row, field, type, 
+         ((bool (*)())(void *)Row::SetData)(row, field, type,
             (type.type == noHeadClass || type.type == normalClass) ? *(void **)data : data);
       }
    }
 
-   public void Init()
+   void Init()
    {
-      if(visible && created)
+      if(created)
          Refresh();
    }
 
@@ -491,17 +516,17 @@ public class FieldDataBox : DataBox
    {
       if((SmartKey)key == enter)
          parent.CycleChildren(true, false, false, true);
-      
+
       return DataBox::OnKeyHit(key, ch);
    }
 
-   public bool Window::NotifyChanged(bool closingDropDown)
+   bool Window::NotifyChanged(DataBox dataBox, bool closingDropDown)
    {
       modifiedDocument = true;
       return true;
    }
 
-   public bool Window::NotifyModified()
+   bool Window::NotifyModified()
    {
       modifiedDocument = true;
       return true;
@@ -514,15 +539,20 @@ public class FieldDataBox : DataBox
 
       if(dataHolder)
       {
-         type._vTbl[__ecereVMethodID_class_OnFree](type, dataHolder);
+         ((void (*)(void *, void *))(void *)type._vTbl[__ecereVMethodID_class_OnFree])(type, (void *)(intptr)dataHolder);
          if(type.type == structClass)
          {
-            void * dataPtr = (void *)dataHolder;
+            void * dataPtr = (void *)(intptr)dataHolder;
             delete dataPtr;
          }
          dataHolder = 0;
       }
    }
+
+private:
+   Field field;
+   int64 dataHolder; // THERE SEEMS(ED?) TO BE A BUG WHEN ACCESSING row ACROSS .so
+   Row row;
 }
 
 public class FieldCheckButton : FieldDataBox
@@ -537,29 +567,23 @@ public class FieldDropDataBox : FieldDataBox
 {
    size.h = 24;
    keepEditor = true;
-
-   Field nameField;
-   Field filterField;
-   uint exclusion;
-   uint filter;
-   bool filtered;
-   bool showNone;
    showNone = true;
 
-   public property uint filter { set { filtered = true; filter = value; } get { return filter; } }
-   public property bool filtered { set { filtered = value; } }
-   public property uint exclusion { set { exclusion = value; } }
-   public property Field filterField { set { filterField = value; } }
-   public property Field nameField { set { nameField = value; } }
-   public virtual void TableDropBox::RefillFunction();
-   public property bool showNone { set { showNone = value; } }
-
-   public void Refill()
+public:
+   property Id filter { set { filtered = true; filter = value; } get { return filter; } }
+   property bool filtered { set { filtered = value; } }
+   property Id exclusion { set { exclusion = value; } }
+   property Field filterField { set { filterField = value; } }
+   property Field nameField { set { nameField = value; } }
+   virtual void TableDropBox::RefillFunction();
+   property bool showNone { set { showNone = value; } }
+
+   void Refill()
    {
       if(editor)
       {
          TableDropBox dropBox = (TableDropBox) editor;
-         uint id = data ? *(uint *)data : MAXDWORD;
+         Id id = data ? *(Id *)data : MAXDWORD;
          OnConfigure(dropBox);
          dropBox.Refill();
          if(id != MAXDWORD) dropBox.SelectRow(dropBox.FindSubRow(id));
@@ -578,12 +602,20 @@ public class FieldDropDataBox : FieldDataBox
       dropBox.exclusion = exclusion;
       dropBox.showNone = showNone;
    }
+
+private:
+   Field nameField;
+   Field filterField;
+   Id exclusion;
+   Id filter;
+   bool filtered;
+   bool showNone;
 }
 
 public class EditFieldDropDataBox : FieldDropDataBox
 {
    // showNone = false;
-
+public:
    void OnConfigure(TableDropBox dropBox)
    {
       FieldDropDataBox::OnConfigure(dropBox);
@@ -594,7 +626,7 @@ public class EditFieldDropDataBox : FieldDropDataBox
    void Save()
    {
       TableDropBox dropBox = (TableDropBox) editor;
-      
+
       if(!dropBox.currentRow && dropBox.contents[0])
       {
          Row row { dropBox.table };
@@ -609,7 +641,7 @@ public class EditFieldDropDataBox : FieldDropDataBox
       FieldDataBox::Save();
    }
 
-   public virtual bool OnAddTextEntry(Row row, TableDropBox dropBox, char * entry)
+   virtual bool OnAddTextEntry(Row row, TableDropBox dropBox, const char * entry)
    {
       row.Add();
       row.SetData(dropBox.nameField, entry);
@@ -619,13 +651,11 @@ public class EditFieldDropDataBox : FieldDropDataBox
 
 public class ListSection : Group
 {
-   text = "List";
+   text = $"List";
    size = { 710, 287 };
    anchor = { left = sgs, top = 32 + sgs * 3, bottom = 55 + sgs * 3 };
-
-   EditSection editor;
-
-   public property EditSection editor
+public:
+   property EditSection editor
    {
       set
       {
@@ -634,7 +664,7 @@ public class ListSection : Group
       }
    }
 
-   public property Table table
+   property Table table
    {
       set
       {
@@ -644,29 +674,28 @@ public class ListSection : Group
             if(table)
             {
                FieldIndex indexedFields[1];
-               
+
                if(!fldId) fldId = table.FindField(defaultIdField);
                if(!fldName) fldName = table.FindField(defaultNameField);
                if(!fldActive) fldActive = table.FindField(defaultActiveField);
-               
+
                indexedFields[0] = { fldId };
                table.Index(1, indexedFields);
-               
+
                editor.editRow.tbl = table;
-               
+
                RefillList();
             }
          }
       }
    }
-   Table table;
-   public Field fldId, fldName, fldActive;
+   Field fldId, fldName, fldActive;
 
-   public virtual DialogResult Window::NotifySaveConfirmation(ListSection listSection)
+   virtual DialogResult Window::NotifySaveConfirmation(ListSection listSection)
    {
-      return MessageBox { master = this, type = yesNoCancel, text = "List Editor", contents = "You have modified this entry. Would you like to save it before proceeding?" }.Modal();
+      return MessageBox { master = this, type = yesNoCancel, text = $"List Editor", contents = $"You have modified this entry. Would you like to save it before proceeding?" }.Modal();
    }
-   
+
    bool OnClose(bool parentClosing)
    {
       if(editor && editor.modifiedDocument)
@@ -685,7 +714,7 @@ public class ListSection : Group
       return true;
    }
 
-   public void RefillList()
+   void RefillList()
    {
       list.Clear();
       //if(fldId && fldName)
@@ -698,11 +727,12 @@ public class ListSection : Group
       editor.modifiedDocument = false;
    }
 
-   public virtual void Window::NotifyRefillList(ListSection listSection, Row r)
+   virtual void Window::NotifyRefillList(ListSection listSection, Row r)
    {
       if(listSection.fldId && listSection.fldName)
       {
-         bool stringName = !strcmp(listSection.fldName.type.dataTypeString, "char *");
+         Class type = listSection.fldName.type;
+         bool stringName = !strcmp(type.dataTypeString, "char *");
          while(r.Next())
          {
             Id id = 0;
@@ -711,27 +741,30 @@ public class ListSection : Group
             if(stringName)
                r.GetData(listSection.fldName, s);
             else
-               s = PrintString("Entry ", id);
+            {
+               s = GetNameString(r, listSection.fldName);
+               // s = PrintString("Entry ", id);
+            }
             listSection.list.AddString(s).tag = id;
             delete s;
          }
       }
    }
 
-   public virtual bool Window::NotifyNew(ListSection listSection, Row r);
+   virtual bool Window::NotifyNew(ListSection listSection, Row r);
 
-   public ButtonStyle btnNew
+   ButtonStyle btnNew
    {
-      this, anchor = { right = shadowS + sgs * 2, top = 24 }, hotKey = altW, text = "New";
+      this, anchor = { right = shadowS + sgs * 2, top = 24 }, hotKey = altW, text = $"New";
 
       bool NotifyClicked(Button button, int x, int y, Modifiers mods)
       {
          list.NotifySelect(this, list, null, 0);
          if(!editor.modifiedDocument)
          {
-            uint id; // = table.rowsCount + 1; // this is bad with deleted rows, won't work, how to have unique id? 
+            Id id; // = table.rowsCount + 1; // this is bad with deleted rows, won't work, how to have unique id?
             Row r { table };
-         
+
             if(r.Last())   // this will reuse ids in cases where the item(s) with the last id have been deleted
             {
                r.GetData(fldId, id);
@@ -739,7 +772,7 @@ public class ListSection : Group
             }
             else
                id = 1;
-         
+
             editor.EditClear();
             {
                bool active = true;
@@ -753,13 +786,13 @@ public class ListSection : Group
                      r.SetData(fldId, id);
                }
                if(!strcmp(fldName.type.dataTypeString, "char *"))
-                  r.SetData(fldName, "[New]");
+                  r.SetData(fldName, $"[New]");
 
                if(fldActive)
                   r.SetData(fldActive, active);
 
                if(NotifyNew(master, this, r))
-                  list.currentRow = list.AddString("[New]");
+                  list.currentRow = list.AddString($"[New]");
                delete r;
             }
 
@@ -772,20 +805,20 @@ public class ListSection : Group
       }
    };
 
-   public virtual bool Window::NotifyDeleteConfirmation(ListSection listSection)
+   virtual bool Window::NotifyDeleteConfirmation(ListSection listSection)
    {
-      return MessageBox {  master = this, type = yesNo, text = "List Editor", 
-                           contents =  "You are about to delete an entry.\n"
-                                       "Do you wish to continue?"
+      return MessageBox {  master = this, type = yesNo, text = $"List Editor",
+                           contents =  $"You are about to delete an entry.\n"
+                                        "Do you wish to continue?"
                   }.Modal() == yes;
    }
 
-   public virtual void Window::NotifyDeleting(ListSection listSection);
-   public virtual void Window::NotifyDeleted(ListSection listSection);
+   virtual void Window::NotifyDeleting(ListSection listSection);
+   virtual void Window::NotifyDeleted(ListSection listSection);
 
-   public ButtonStyle btnDelete
+   ButtonStyle btnDelete
    {
-      this, anchor = { right = shadowS + sgs * 2, top = 24 }, hotKey = altD, text = "Delete";
+      this, anchor = { right = shadowS + sgs * 2, top = 24 }, hotKey = altD, text = $"Delete";
 
       bool NotifyClicked(Button button, int x, int y, Modifiers mods)
       {
@@ -809,7 +842,7 @@ public class ListSection : Group
       }
    };
 
-   public bool FilterNotifyChanged(bool closeDropDown)
+   bool FilterNotifyChanged(DataBox dataBox, bool closeDropDown)
    {
       editor.EditClear();
       RefillList();
@@ -819,18 +852,16 @@ public class ListSection : Group
       return true;
    }
 
-   DataRow lastRow;
-   public ListBox list
+   ListBox list
    {
       this, anchor = { left = sgs * 2, top = 22 + 22 + sgs * 4, right = shadowS + sgs * 2, bottom = shadowS + sgs * 2 };
       alwaysHighLight = true;
-      
+
       bool NotifySelect(ListBox listBox, DataRow row, Modifiers mods)
       {
          bool result = true;
          if(/*row && */row != lastRow)
          {
-            uint id;
             if(editor.modifiedDocument)
             {
                if(row)
@@ -854,14 +885,14 @@ public class ListSection : Group
       }
    };
 
-   public virtual void Window::NotifySelectListRow(ListSection listSection, uint id);
-   
-   public void SelectListRow(DataRow row)
+   virtual void Window::NotifySelectListRow(ListSection listSection, Id id);
+
+   void SelectListRow(DataRow row)
    {
       // Time startTime = GetTime();
       if(row)
       {
-         uint id = row.tag;
+         Id id = row.tag;
          lastRow = row;
 
          if(list.currentRow != row)
@@ -876,24 +907,24 @@ public class ListSection : Group
       // Logf("SelectListRow took %f seconds\n", GetTime() - startTime);
    }
 
-   public void SelectFirst()
+   void SelectFirst()
    {
       if(list.firstRow)
          SelectListRow(list.firstRow);
       RefreshState();
    }
 
-   public void RefreshState()
+   void RefreshState()
    {
       if(editor)
       {
-         editor.btnSave.disabled = !(bool)list.currentRow;
-         editor.btnReload.disabled = !(bool)list.currentRow;
-         btnDelete.disabled = !(bool)list.currentRow;
-         editor.disabled = !(bool)list.firstRow;
+         editor.btnSave.disabled = !list.currentRow;
+         editor.btnReload.disabled = !list.currentRow;
+         btnDelete.disabled = !list.currentRow;
+         editor.disabled = !list.firstRow;
       }
    }
-   
+
    void OnResize(int width, int height)
    {
       int x = width - btnDelete.size.w - 20;
@@ -911,12 +942,16 @@ public class ListSection : Group
       return Window::OnPostCreate();
    }
 
+private:
+   EditSection editor;
+   Table table;
+   DataRow lastRow;
 }
 
 public class EditSection : Group
 {
    tabCycle = true;
-   text = "Entry";
+   text = $"Entry";
    size = { 710, 55 };
    anchor = { right = sgs, top = 32 + sgs * 3, bottom = 55 + sgs * 3 };
 
@@ -945,26 +980,26 @@ public:
    DataRow listRow;
    OldList editBoxes { };
 
-   public Window editArea { this, borderStyle = deep, tabCycle = true, anchor = { left = 8, top = 54, right = 10, bottom = 10 }, hasVertScroll = true, dontHideScroll = true };
-   
-   public ButtonStyle btnSave
+   Window editArea { this, borderStyle = deep, tabCycle = true, anchor = { left = 8, top = 54, right = 10, bottom = 10 }, hasVertScroll = true, dontHideScroll = true };
+
+   ButtonStyle btnSave
    {
-      this, anchor = { right = shadowS + sgs * 2, top = 24 }, hotKey = altV, text = "Save";
+      this, anchor = { right = shadowS + sgs * 2, top = 24 }, hotKey = altV, text = $"Save";
 
       bool NotifyClicked(Button button, int x, int y, Modifiers mods)
       {
-         EditSave(editRow);
+         EditSave();
          return true;
       }
    };
 
-   public ButtonStyle btnReload
+   ButtonStyle btnReload
    {
-      this, anchor = { left = 10, top = 24 }, hotKey = altV, text = "Revert";
+      this, anchor = { left = 10, top = 24 }, hotKey = altV, text = $"Revert";
 
       bool NotifyClicked(Button button, int x, int y, Modifiers mods)
       {
-         EditLoad(editRow);
+         EditLoad();
          return true;
       }
    };
@@ -976,7 +1011,7 @@ public:
    }
 
    virtual void Window::NotifyInitFields(EditSection editSection);
-   
+
    void InitFields()
    {
       OldLink link;
@@ -990,7 +1025,6 @@ public:
 
    void EditNew()
    {
-
       modifiedDocument = false;
    }
 
@@ -998,19 +1032,20 @@ public:
    {
       edit.listRow.string = name;
    }
-   
+
    void EditSave()
    {
       bool stringName = !strcmp(list.fldName.type.dataTypeString, "char *");
       OldLink link;
       String name = null;
 
+      editRow.tbl.db.Begin();
       for(link = editBoxes.first; link; link = link.next)
       {
          FieldDataBox dataBox = link.data;
          dataBox.Save();
       }
-
+      editRow.tbl.db.Commit();
       // ADDED THIS HERE FOR SQLITE TO REFRESH
       editRow.Find(list.fldId, middle, nil, list.list.currentRow.tag);