How to use CallOutBox?

Trying to use CallOutBox for the first time. I have it working, but I have a few questions.

[]Why is the background colour so dark? It makes it almost impossible to read things like toggle buttons, text labels or groupboxes in the callout.[/]
[]Is there a way to change the background colour? I see no colour ID within CallOutBox.[/]
[]There are several private attributes that look interesting, such as background image and borderSpace, but I see no way to set these. Did I miss a method?[/][/list]

Is this what CallOutBox looks like on all platforms, or is this a linux/Ubuntu quirk?

Yes, the CallOutBox does use a dark background color by default. You can change that by overwriting drawCallOutBoxBackground in your own LookAndFeel subclass. I simply copied over the drawing code from the default LookAndFeel and used a different color for drawing the background:

[code]void SWLookAndFeel::drawCallOutBoxBackground(CallOutBox& box, Graphics& g, const Path& path, Image& cachedImage)
if (cachedImage.isNull())
cachedImage = Image (Image::ARGB, box.getWidth(), box.getHeight(), true);
Graphics g2 (cachedImage);

	DropShadow (Colours::black.withAlpha (0.7f), 8, Point<int> (0, 2)).drawForPath (g2, path);

g.setColour (Colours::black);
g.drawImageAt (cachedImage, 0, 0);

//g.setColour (Colour::greyLevel (0.23f).withAlpha (0.9f));
g.fillPath (path);

g.setColour (Colours::black);
g.strokePath (path, PathStrokeType (2.0f));


Thanks for the tip, P4tr3ck, but...seriously? You really can't put text in a CallOutBox without writing a custom look and feel? That seems pretty broken by design.

I've been trying to use a CallOutBox with various components inside, and this whole time I assumed I was doing something wrong. What is the intended use of a CallOutBox if they can't even display text labels with the default look and feel? Maybe I'm not supposed to be using CallOutBoxes for showing a collection of widgets with text labels?

You can put any component you like inside a CalloutBox, it's just a container. You can put a text label in it or whatever you want. People seem a little confused by it, but I don't quite understand why..

Sorry, I didn't mean it wasn't possible to add text to a CallOutBox. It's certainly possible, just the results are visually terrible. Here are a couple screenshots.

This is from a little application I'm experimenting with:

Yes, the text appears just like I expected, but it's almost unreadable. That's the problem I'm having. I could write a new look and feel to deal with this, but I'm surprised it's necessary. Am I missing something, or is text unreadable by default in a CallOutBox?

Here's a screenshot from the JUCE demo program. The color picker:

Yes, I can read the text, but it's far from clear. I can imagine that some people would actually find it very difficult or impossible to read.

I'll write a look and feel if that's what I need to do. I just don't want to be taking a more complicated approach than necessary.

You can use setColour() to change the color of a Label’s text without using a LookAndFeel

Look up Label::ColourIds


You could do that, but what if you have a component that you want to use in multiple places - sometimes in a CallOutBox, sometimes not.

The design of components is quite elegant in that you can have a parent component with a very complex set of children, and you can put that in a window, or a CallOutBox, or a modal dialog, or as a child of another component, or...

Think about the color picker, specifically. I don't want to know about the implementation of it - if I have to set the color of the red, green, blue, and alpha labels just because I'm using a CallOutBox, then I know too much about the internals of the color picker.

Is there a way for the setColour function (or somthing similar) to cascade down to all children of the calling component? Then I could call setColour(Label::textColourId, Colours::white) on the CallOutBox. That way, I wouldn't have to have pointers to all the Labels.

Well if you wanted to it would be trivial for the CallOutBox to iterate through all it’s children and find any Labels and change their colour… but personally I’d find it easier to subclass Label with my own version with white text and just use that.

You could subclass CallOutBox and add that functionality very easily using Component:: getNumChildComponents(), Component:: getChildComponent() and dynamic_cast