ecere, eda: GUI Tweaks to fix autoSize behaviors
authorJerome St-Louis <jerome@ecere.com>
Sat, 14 Jul 2012 15:29:53 +0000 (11:29 -0400)
committerJerome St-Louis <jerome@ecere.com>
Sat, 14 Jul 2012 15:29:53 +0000 (11:29 -0400)
ecere/src/gui/controls/DataBox.ec
ecere/src/gui/controls/ListBox.ec
ecere/src/gui/typeEdit.ec
eda/libeda/src/gui/TableEditor.ec

index 076f1ef..fe2774f 100644 (file)
@@ -98,7 +98,8 @@ private:
 
    bool OnPostCreate()
    {
-      if(type && !readOnly && (type.type == normalClass || type.type == noHeadClass || data))
+      if(type && (!readOnly || (autoSize && type._vTbl[__ecereVMethodID_class_OnEdit] == class(Instance)._vTbl[__ecereVMethodID_class_OnEdit])) &&
+         (type.type == normalClass || type.type == noHeadClass || data))
       {
          // IMPORTANT FIX: If keepEditor is true, we were passing editor rather than the editor's current master
          editor = (Window)type._vTbl[__ecereVMethodID_class_OnEdit](type, 
@@ -115,7 +116,10 @@ private:
                PrintLn("DataBox::OnPostCreate -- autoSize == true");
 #endif*/
             if(eClass_IsDerived(editor._class, class(EditBox)))
+            {
+               ((EditBox)editor).readOnly = readOnly;
                ((EditBox)editor).autoSize = autoSize;
+            }
          }
          else
          {
@@ -129,7 +133,7 @@ private:
 
    void OnRedraw(Surface surface)
    {
-      if(type)
+      if(type && !editor)
       {
          char tempString[1024];
          if(type._vTbl[__ecereVMethodID_class_OnDisplay] == class(Instance)._vTbl[__ecereVMethodID_class_OnDisplay])
index bc28f36..e233773 100644 (file)
@@ -1072,6 +1072,7 @@ public:
 #ifdef _DEBUG
    private void CheckConsistency()
    {
+#if 0
       DataRow r;
       int index = 0;
       for(r = rows.first; r; r = r.GetNextRow())
@@ -1079,6 +1080,7 @@ public:
          if(r.index != index++)
             PrintLn("bug");
       }
+#endif
    }
 #endif
 
index 2e5320e..dcd4121 100644 (file)
@@ -172,8 +172,7 @@ static Window OnEdit(Class _class, void * data, Window window, Window master,
          window, master = master, visible = false, //position = { x, y }, 
          borderStyle = 0,
          modifyVirtualArea = false, //sizeAnchor = { { w, h }, isClientH = true };
-         autoSize = (eClass_IsDerived(window._class, class(DataBox)) ? ((DataBox)window).autoSize : false),
-         anchor = { 0, 0, 0, 0 };
+         autoSize = (eClass_IsDerived(window._class, class(DataBox)) ? ((DataBox)window).autoSize : false);
 
          void DataBox::NotifyUpdate(EditBox editBox)
          {
@@ -183,10 +182,15 @@ static Window OnEdit(Class _class, void * data, Window window, Window master,
 
          bool OnActivate(bool active, Window previous, bool * goOnWithActivation, bool direct)
          {
-            opacity = active ? 1.0f : parent.opacity;
+            opacity = (active && !readOnly) ? 1.0f : parent.opacity;
             return EditBox::OnActivate(active, previous, goOnWithActivation, direct);
          }
       };
+      if(!editBox.autoSize)
+         editBox.anchor = { 0, 0, 0, 0 };
+      else
+         editBox.anchor = { 0, 0 };
+
       if(data)
       {
          bool needClass = false;
index 5b82561..ebc8e20 100644 (file)
@@ -1321,6 +1321,11 @@ private:
 
    void AddFieldBox(FieldBox fieldBox)
    {
+      // I was putting this here to force autosize on the lists (e.g. the Radiologists fields):
+      /*
+      if(!fieldBox.autoSize)
+         fieldBox.autoSize = true;
+      */
       DebugLn("TableEditor::AddFieldBox");
       if(!fieldsBoxes.Find(fieldBox))
       {
@@ -1420,6 +1425,7 @@ private:
          fb.Load();
       OnCreateDynamicLookupEditors();
       internalModifications = false;
+      size = size;   // This seems to be required to fix autoSize on entering order screen
 
       DebugLn("   TODO: implement virtual method TableEditor::OnSubEditorsLoad");