ide/sdk: Fixed forcing bit depth option not invoked for static libraries
[sdk] / eda / libeda / src / idList.ec
index 363aab1..9da121d 100644 (file)
@@ -33,6 +33,8 @@ private:
 public class Id : uint
 {
    class_data Table * table;     class_property Table * table     { set { class_data(table) = value; } get { return class_data(table); } };
+   //class_data Field * idField; class_property Field * idField { set { class_data(nameField) = value; } get { return class_data(idField); } };
+   //class_data Field * displayField; class_property Field * displayField { set { class_data(displayField) = value; } get { return class_data(displayField); } };
    class_data Field * nameField; class_property Field * nameField { set { class_data(nameField) = value; } get { return class_data(nameField); } };
    class_data char * addText;   class_property char * addText  { set { class_data(addText) = value; } };
    class_data void * Refill;    class_property void * Refill   { set { class_data(Refill) = value; } };
@@ -43,6 +45,19 @@ public class Id : uint
          TableDropBox dropBox = dataBox.keepEditor ? (TableDropBox)dataBox.editor /*obsolete*/ : null;
          if(!dropBox)
          {
+/*
+            if(eClass_IsDerived(dataBox._class, class(FieldDropBox)))
+            {
+               FieldDropBox fieldDropBox = (FieldDropBox)dataBox;
+
+            }
+            else if(eClass_IsDerived(dataBox._class, class(FieldBox)))
+            {
+               FieldBox fieldBox = (FieldBox)dataBox;
+
+            }
+*/
+
             dropBox = TableDropBox
             {
                dataBox, borderStyle = 0, anchor = { 0, 0, 0, 0 }, 
@@ -159,7 +174,14 @@ public class Id : uint
          // FIXME
          Table tbl = *class_data(table);
          Field idField = tbl.FindField(defaultIdField);
-         Row r { tbl };
+         Row r;
+         idRowCacheMutex.Wait();
+         if(!tbl.cachedIdRow)
+         {
+            tbl.cachedIdRow = Row { tbl };
+            incref tbl.cachedIdRow;
+         }
+         r = tbl.cachedIdRow;
 
          if(this)
          {
@@ -167,22 +189,47 @@ public class Id : uint
             {
                String name = null;
                Field * nameField = class_data(nameField);
-               char * fn = nameField->name;
-               r.GetData(*nameField, name);
-               if(name)
+               if(nameField)
                {
-                  strcpy(tempString, name);
-                  delete name;
+#ifdef _DEBUG
+                  char * fn = nameField->name;
+#endif
+                  // Get name data from row
+                  int64 data = 0;
+                  Class type = nameField->type;
+                  if(type.type == unitClass && !type.typeSize)
+                  {
+                     Class dataType = eSystem_FindClass(type.module, type.dataTypeString);
+                     if(dataType)
+                        type = dataType;
+                  }
+                  if(type.type == structClass)
+                     data = (int64)new0 byte[type.structSize];
+                  ((bool (*)())(void *)r.GetData)(r, *nameField, type, (type.type == structClass) ? (void *)data : &data);
+
+                  if(type.type == systemClass || type.type == unitClass || type.type == bitClass || type.type == enumClass)
+                     name = (String)type._vTbl[__ecereVMethodID_class_OnGetString](type, (void *)&data, tempString, null, null);
+                  else
+                     name = (String)type._vTbl[__ecereVMethodID_class_OnGetString](type, (void *)data, tempString, null, null);
+
+                  strcpy(tempString, name ? name : "");
+                  if(!(type.type == systemClass || type.type == unitClass || type.type == bitClass || type.type == enumClass))
+                     type._vTbl[__ecereVMethodID_class_OnFree](type, data);
                }
                else
-                  strcpy(tempString, "");
+               {
+                  PrintLn("Id::OnGetString -- data type"/*, this._class.name, */" has no class_data(nameField)");
+               }
             }
+            else
+               sprintf(tempString, "(Invalid %s entry: %d)", tbl.name, this);
          }
          else
          {
             sprintf(tempString, $"(Click to add a new %s...)", $"item"/*class_data(addText)*/);
          }
-         delete r;
+         // delete r;
+         idRowCacheMutex.Release();
       }
       return tempString;
    }
@@ -289,11 +336,12 @@ public:
          channel.Serialize(none);
       }
    }
-
+   /*
    void OnDisplay(Surface surface, int x, int y, int width, void * fieldData, Alignment alignment, DataDisplayFlags displayFlags)
    {
 
    }
+   */
    
    char * OnGetString(char * stringOutput, void * fieldData, bool * needClass)
    {
@@ -328,7 +376,10 @@ public:
 
    int OnCompare(IdList b)
    {
-      if(count > b.count) return 1;
+      if(!this && !b) return 0;
+      else if(this && !b) return 1;
+      else if(!this && b) return -1;
+      else if(count > b.count) return 1;
       else if(count < b.count) return -1;
       else
       {
@@ -449,7 +500,7 @@ public class StringList
 
    bool Add(String string)
    {
-      BTNode node { key = (uint)CopyString(string) };
+      BTNode node { key = (uintptr)CopyString(string) };
       if(strings.Add(node))
          return true;
       else
@@ -725,6 +776,7 @@ public class MultiLineString : String
          borderStyle = 0,
          hasHorzScroll = true, hasVertScroll = true,
          modifyVirtualArea = false,
+         autoSize = dataBox.autoSize;
          anchor = { 0, 0, 0, 0 };
          multiLine = true;
 
@@ -733,6 +785,12 @@ public class MultiLineString : String
             Modified();
             modifiedDocument = true;
          }
+
+         bool OnActivate(bool active, Window previous, bool * goOnWithActivation, bool direct)
+         {
+            opacity = active ? 1.0f : parent.opacity;
+            return true;
+         }
       };
       editBox.contents = this;
       editBox.visible = true;