ecere:gui:DataBox; let EditBox implement readOnly behavior. allow copying readonly...
[sdk] / ecere / src / gui / controls / DataBox.ec
index a6efd8c..fa285dc 100644 (file)
@@ -54,7 +54,7 @@ public:
          }
       }
       if(created)
-         NotifyChanged(master, closingDropDown);
+         NotifyChanged(master, this, closingDropDown);
       //editor.Activate();
    }
 
@@ -63,7 +63,7 @@ public:
       if(editor && ((bool (*)(void *, void *, Window, void *))(void *)type._vTbl[__ecereVMethodID_class_OnSaveEdit])(type, data, editor, null))
       {
          Refresh();
-         NotifyChanged(master, false);
+         NotifyChanged(master, this, false);
          // Refresh();
          return true;
       }
@@ -90,23 +90,36 @@ public:
    }
 
    virtual bool Window::NotifyModified();
-   virtual bool Window::NotifyChanged(bool closingDropDown);
+   virtual bool Window::NotifyChanged(DataBox dataBox, bool closingDropDown);
    virtual void OnConfigure(Window editor);
 
 private:
    bool inAutoSize;
 
+   watch(background)     { if(editor) editor.background = background; };
+   watch(foreground)     { if(editor) editor.foreground = foreground; };
+   //watch(selectionColor) { if(editor) editor.selectionColor = selectionColor; };
+   //watch(selectionText)  { if(editor) editor.selectionText = selectionText; };
+   watch(opacity)        { if(editor) editor.opacity = opacity; };
+
    bool OnPostCreate()
    {
       // Right now for read-only DataBoxes the only reason we'd want to create an editor is for autoSize purposes, when using the default EditBox editor that supports it.
       // ( A tweak for enum classes is in typeEdit.ec, as the base class editor invokes it )
-      if(type && (!readOnly || (autoSize && type._vTbl[__ecereVMethodID_class_OnEdit] == class(Instance)._vTbl[__ecereVMethodID_class_OnEdit])) &&
+      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 (*)(void *, void *, DataBox, void *, int, int, int, int, void*))(void *)type._vTbl[__ecereVMethodID_class_OnEdit])(type,
             (type.type == normalClass || type.type == noHeadClass) ? (data ? (*(void **)data) : null) : data,
             this, (keepEditor && editor) ? editor.master : this, 0, 0, clientSize.w, clientSize.h, fieldData);// null);
+         if(editor && readOnly && !eClass_IsDerived(editor._class, class(EditBox)) &&
+               !(autoSize && type._vTbl[__ecereVMethodID_class_OnEdit] == class(Instance)._vTbl[__ecereVMethodID_class_OnEdit]))
+         {
+            editor.Destroy(0);
+            editor = null;
+            return true;
+         }
          if(editor)
          {
             // editor.anchor = { 0, 0, 0, 0 };