wip II
[sdk] / eda / libeda / src / gui / TableEditor.ec
index c6caba8..300e8b6 100644 (file)
@@ -120,7 +120,7 @@ public:
       buffer.buffer = ptr;
       buffer.count = MAXINT;
       buffer.pos = 0;
-      class(NT)._vTbl[__ecereVMethodID_class_OnUnserialize](class(NT), &pn, buffer);
+      ((void (*)(void *, void *, void *))(void *)class(NT)._vTbl[__ecereVMethodID_class_OnUnserialize])(class(NT), &pn, buffer);
       result = NoCaseAccent::function((pn && pn.name) ? pn.name : null);
       delete pn;
       buffer.buffer = null;
@@ -135,7 +135,6 @@ public:
 // Rename TableEditor to TableControl and move to eda/src/gui/controls
 public class TableEditor : public Window
 {
-   bool initialized;
 public:
    property Table table
    {
@@ -144,8 +143,8 @@ public:
          DebugLn("TableEditor::table|set");
          table = value;
       }
+      get { return table; }
    }
-   Table table;
 
    property Table index
    {
@@ -155,8 +154,8 @@ public:
          index = value;
          filterRow.tbl = index;
       }
+      get { return index; }
    }
-   Table index;
 
    bool OnPostCreate()
    {
@@ -212,11 +211,6 @@ public:
          //ResetListFields();
       }
    }
-   Field idField;
-   Field stringField;
-   Field indexFilterField;
-
-   ListBox list;
    property Array<ListField> listFields
    {
       set
@@ -226,10 +220,21 @@ public:
          //ResetListFields();
       }
    }
-   Array<ListField> listFields;
-   int listSortOrder;
-   DataField listSortField;
-   bool disabledFullListing;
+   property int listSortOrder
+   {
+      set { listSortOrder = value; }
+      get { return listSortOrder; }
+   }
+   property DataField listSortField
+   {
+      set { listSortField = value; }
+      get { return listSortField; }      
+   }
+   property bool disabledFullListing
+   {
+      set { disabledFullListing = value; }
+      get { return disabledFullListing; }
+   }
 
    property Array<StringSearchField> searchFields
    {
@@ -256,7 +261,6 @@ public:
          searchTables = value;
       }
    }
-   Array<StringSearchTable> searchTables;
 
    property Array<SQLiteSearchTable> sqliteSearchTables
    {
@@ -270,7 +274,6 @@ public:
          sqliteSearchTables = value;
       }
    }
-   Array<SQLiteSearchTable> sqliteSearchTables;
 
    property String searchString
    {
@@ -295,11 +298,6 @@ public:
          }
       }
    }
-   String searchString;
-
-   Map<Table, Lookup> lookups;
-
-   Array<LookupEditor> dynamicLookupEditors;
    property Array<LookupEditor> dynamicLookupEditors
    {
       set
@@ -312,27 +310,43 @@ public:
    // Fields Editor
    property Id selectedId { get { return selectedId; } }
 
-   Array<FieldBox> fieldsBoxes { };
-   Array<TableEditor> tableEditors { };
-   Array<TableEditor> dynamicLookupTableEditors { };
+   property Field idField
+   {
+      set { idField = value; }
+      get { return idField; }
+   }
+   property Field stringField
+   {
+      set { stringField = value; }
+      get { return stringField; }
+   }
+   property Field indexFilterField
+   {
+      set { indexFilterField = value; }
+      get { return indexFilterField; }
+   }
 
-   bool readOnly;
-   
-   public virtual void OnInitialize();
-   public virtual void OnLoad();
-   public virtual void OnStateChanged();
-   bool internalModifications;
-   public void NotifyModifiedDocument()
+   property bool readOnly
+   {
+      set { readOnly = value; }
+      get { return readOnly; }
+   }
+
+   virtual void OnInitialize();
+   virtual void OnLoad();
+   virtual void OnStateChanged();
+
+   void NotifyModifiedDocument()
    {
       DebugLn("TableEditor::NotifyModifiedDocument");
       if(!internalModifications)
          OnStateChanged();
    }
 
-   //public virtual bool Window::NotifyNew(AltListSection listSection, Row r);
+   //virtual bool Window::NotifyNew(AltListSection listSection, Row r);
    //virtual void Window::NotifyInitFields(AltEditSection editSection);
    
-   public virtual DialogResult OnLeavingModifiedDocument()
+   virtual DialogResult OnLeavingModifiedDocument()
    {
       DebugLn("TableEditor::OnLeavingModifiedDocument");
       return MessageBox { master = this, type = yesNoCancel, text = text && text[0] ? text : $"Table Editor",
@@ -340,7 +354,7 @@ public:
                   }.Modal();
    }
    
-   public virtual bool OnRemovalRequest()
+   virtual bool OnRemovalRequest()
    {
       DebugLn("TableEditor::OnRemovalRequest");
       return MessageBox { master = this, type = yesNo, text = text && text[0] ? text : $"Table Editor",
@@ -349,10 +363,10 @@ public:
                   }.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 bool NotifyClosing()
+   bool NotifyClosing()
    {
       bool result = true;
       DebugLn("TableEditor::NotifyClosing");
@@ -378,8 +392,8 @@ public:
       return result;
    }
 
-   //public void List() // this gets called out of nowhere by some constructor thing...
-   public void Enumerate()
+   //void List() // this gets called out of nowhere by some constructor thing...
+   void Enumerate()
    {
       DebugLn("TableEditor::Enumerate");
       if(list)
@@ -470,9 +484,7 @@ public:
       }
    }
 
-   TableEditor masterEditor;
-
-   public property TableEditor masterEditor
+   property TableEditor masterEditor
    {
       set
       {
@@ -485,6 +497,7 @@ public:
                value.AddTableEditor(this);
          }
       }
+      get { return masterEditor; }
    }
 
    watch(parent)
@@ -499,6 +512,11 @@ public:
          property::masterEditor = (TableEditor)master;
    };
 
+   watch(modifiedDocument)
+   {
+      NotifyModifiedDocument();
+   };
+
    void CreateRow()
    {
       DebugLn("TableEditor::CreateRow");
@@ -585,10 +603,10 @@ public:
                               data = &dataHolder;
                            }*/
                            if(data)
-                              dataType._vTbl[__ecereVMethodID_class_OnGetDataFromString](dataType, data, newText);
+                              ((bool (*)(void *, void *, const char *))(void *)dataType._vTbl[__ecereVMethodID_class_OnGetDataFromString])(dataType, data, newText);
 
 
-                           /*dataType._vTbl[__ecereVMethodID_class_OnFree](dataType, dataHolder);
+                           /*((void (*)(void *, void *))(void *)dataType._vTbl[__ecereVMethodID_class_OnFree])(dataType, dataHolder);
                            if(dataType.type == structClass)
                            {
                               void * dataPtr = (void *)dataHolder;
@@ -824,7 +842,8 @@ public:
       DebugLn("TableEditor::SelectListRow");
       if(row)
       {
-         selectedId = row.tag;
+         // TOFIX: Id is still 32-bit; Also the warning without this cast seems wrong (It says row.tag is of type eda::Id, while it is int64)
+         selectedId = (Id)row.tag;
          lastRow = row;
 
          if(list.currentRow != row)
@@ -840,6 +859,28 @@ public:
    }
 
 private:
+   Table table;
+   Table index;
+   Field idField;
+   Field stringField;
+   Field indexFilterField;
+
+   ListBox list;
+   Array<StringSearchTable> searchTables;
+   Array<SQLiteSearchTable> sqliteSearchTables;
+   String searchString;
+
+   Map<Table, Lookup> lookups;
+
+   Array<LookupEditor> dynamicLookupEditors;
+   Array<FieldBox> fieldsBoxes { };
+   Array<TableEditor> tableEditors { };
+   Array<TableEditor> dynamicLookupTableEditors { };
+
+   bool readOnly;
+   bool internalModifications;
+   TableEditor masterEditor;
+
    Row editRow { };
    DataRow listRow;
    DataRow lastRow;
@@ -847,6 +888,13 @@ private:
    Row filterRow { };
    bool filtered;
    Array<char> searchCI { };
+   WordEntry letters[26];
+   WordEntry doubleLetters[26][26];
+   bool initialized;
+   Array<ListField> listFields;
+   int listSortOrder;
+   DataField listSortField;
+   bool disabledFullListing;
 
    ListEnumerationTimer listEnumerationTimer
    {
@@ -1055,7 +1103,7 @@ private:
                               if(strstr(sf.field.type.name, "PersonName"))
                               {
                                  void * pn;
-                                 sf.field.type._vTbl[__ecereVMethodID_class_OnGetDataFromString](sf.field.type, &pn, searchCI.array);
+                                 ((bool (*)(void *, void *, const char *))(void *)sf.field.type._vTbl[__ecereVMethodID_class_OnGetDataFromString])(sf.field.type, &pn, searchCI.array);
                                  row.SetQueryParamObject(++bindId, pn, sf.field.type);
                                  bindId++;
                                  delete pn;
@@ -1254,6 +1302,7 @@ private:
                      char tempString[MAX_F_STRING];
                      int64 data = 0;
                      Class type = field.type;
+                     String s;
                      if(type.type == unitClass && !type.typeSize)
                      {
                         Class dataType = eSystem_FindClass(type.module, type.dataTypeString);
@@ -1265,15 +1314,15 @@ private:
                      ((bool (*)())(void *)row.GetData)(row, field, type, (type.type == structClass) ? (void *)data : &data);
 
                      if(type.type == systemClass || type.type == unitClass || type.type == bitClass || type.type == enumClass)
-                        field.type._vTbl[__ecereVMethodID_class_OnGetString](field.type, &data, tempString, null, null);
+                        s = ((char *(*)(void *, void *, char *, void *, bool *))(void *)field.type._vTbl[__ecereVMethodID_class_OnGetString])(field.type, &data, tempString, null, null);
                      else
-                        field.type._vTbl[__ecereVMethodID_class_OnGetString](field.type, (void *)data, tempString, null, null);
+                        s = ((char *(*)(void *, void *, char *, void *, bool *))(void *)field.type._vTbl[__ecereVMethodID_class_OnGetString])(field.type, (void *)data, tempString, null, null);
 
-                     if(tempString[0])
-                        ProcessWordListString(tempString, method, id);
+                     if(s && s[0])
+                        ProcessWordListString(s, method, id);
 
                      if(!(type.type == systemClass || type.type == unitClass || type.type == bitClass || type.type == enumClass))
-                        type._vTbl[__ecereVMethodID_class_OnFree](type, data);
+                        ((void (*)(void *, void *))(void *)type._vTbl[__ecereVMethodID_class_OnFree])(type, (void *)data);
                      if(type.type == structClass)
                         delete data;
                   }
@@ -1570,7 +1619,7 @@ private:
                s = lf.CustomLookup((int)data);
                listRow.SetData(lf.dataField, s);
                if(!(type.type == systemClass || type.type == unitClass || type.type == bitClass || type.type == enumClass))
-                  type._vTbl[__ecereVMethodID_class_OnFree](type, data);
+                  ((void (*)(void *, void *))(void *)type._vTbl[__ecereVMethodID_class_OnFree])(type, (void *)data);
                if(type.type == structClass)
                   delete data;
                delete s; // ?
@@ -1581,6 +1630,7 @@ private:
                char tempString[MAX_F_STRING];
                int64 data = 0;
                Class type = lf.field.type;
+               String s;
                if(type.type == unitClass && !type.typeSize)
                {
                   Class dataType = eSystem_FindClass(type.module, type.dataTypeString);
@@ -1591,14 +1641,14 @@ private:
                   data = (int64)new0 byte[type.structSize];
                ((bool (*)())(void *)dbRow.GetData)(dbRow, lf.field, type, (type.type == structClass) ? (void *)data : &data);
                if(type.type == systemClass || type.type == unitClass || type.type == bitClass || type.type == enumClass)
-                  lf.field.type._vTbl[__ecereVMethodID_class_OnGetString](lf.field.type, &data, tempString, null, null);
+                  s = ((char *(*)(void *, void *, char *, void *, bool *))(void *)lf.field.type._vTbl[__ecereVMethodID_class_OnGetString])(lf.field.type, &data, tempString, null, null);
                else
-                  lf.field.type._vTbl[__ecereVMethodID_class_OnGetString](lf.field.type, (void*)data, tempString, null, null);
+                  s = ((char *(*)(void *, void *, char *, void *, bool *))(void *)lf.field.type._vTbl[__ecereVMethodID_class_OnGetString])(lf.field.type, (void*)data, tempString, null, null);
 
-               listRow.SetData(lf.dataField, tempString);
+               listRow.SetData(lf.dataField, s);
 
                if(!(type.type == systemClass || type.type == unitClass || type.type == bitClass || type.type == enumClass))
-                  type._vTbl[__ecereVMethodID_class_OnFree](type, data);
+                  ((void (*)(void *, void *))(void *)type._vTbl[__ecereVMethodID_class_OnFree])(type, (void *)data);
                if(type.type == structClass)
                   delete data;
             }
@@ -1622,7 +1672,7 @@ private:
                else
                   listRow.SetData(lf.dataField, (void *)data);
                if(!(type.type == systemClass || type.type == unitClass || type.type == bitClass || type.type == enumClass))
-                  type._vTbl[__ecereVMethodID_class_OnFree](type, data);
+                  ((void (*)(void *, void *))(void *)type._vTbl[__ecereVMethodID_class_OnFree])(type, (void *)data);
                if(type.type == structClass)
                   delete data;
             }
@@ -1835,9 +1885,6 @@ private:
       FreeKey = BinaryTree::FreeString;
    };
 
-   WordEntry letters[26];
-   WordEntry doubleLetters[26][26];
-
    void AddWord(char * word, int count, bool addAllSubstrings, Id id)
    {
       //DebugLn("TableEditor::AddWord");