This might be complicated... You do not get any parameters in the defaultValue call (at least not in 3.2) and this only points to your own object. You might try to save a reference somewhere and use that (perhaps in the paint method, check if you are in edit mode, then save what you want in a var, use it in defaultValue function).
Another option I have used is to not set any default value and then instead set it in paint:
var myprop = layout.myprop || calcDefault(layout);
Hope this helps