How to create 'visible objects' with underlying data and functionality

Dear All,

My question is quite simple, there are several function that return objects/functions with pictorial representations:

I was wondering if there is a general construct to create your own object/function that shows some details, and to one can apply values to (like for ColorData apply a value between 0 and 1 to get a color). Mainly because all of them look very similar, so I guess there is a function that can do this…

I am trying to dig through this myself, but I do not quite understand this. It might be related to the Low-Level Notebook Structure described also a bit in the tutorial Representing Textual Forms by Boxes. If you look with CMD+SHIFT+E on those structures you can see things like InterpretationBox and TemplateBox.

ColorData["Rainbow"]

InterpretationBox makes a formatting structure whose interpretation is not based on its appearance. For example, lets compute these:

Plot[Sin[x] Cos[5 x], {x, 0, 15/4}, PlotTheme -> "Minimal", Filling -> 0]
Integrate[Sin[x] Cos[5 x], {x, 0, 15/4}]

and now pack them as

Now the last output is interpreted as the expression in its second argument:

I doubt this is really helpful. I also would be curious about user-built case for such structures.

I didn’t know about CMD+SHIFT+E. Very interesting structure indeed… I’ll investigate a bit more, thanks a lot!

Perhaps you also need to set Format[YourOwnFunction] := … ?

Anyone from Wolfram that could give me some insight? Surely there must be a function under the hood that can accomplish this…

@Leonid Shifrin @Vitaliy Kaurov @Jon McLoone @Michael Trott ?

The problem was already discussed here:

“How to create a dynamic expanding DisplayForm’s styled like the ones in v10?”

Thanks @Alexey Popkov. That is part of the story, I would like to make it such that it can be interpreted again, like the things colordata makes:

i.e. you can copy the output and add [value] to it, and it will execute… This seems to be a bit trickier to make…