Set Color of a checkbutton

Hi

Can I set the background color of a check button?
I mean the small box where the “check” is inside.

Cheers,
delos

Hi,

No, this is not possible, except if you want to change it globally: since the checkbox itself uses pixmaps:

fOn = fClient->GetPicture("checked_t.xpm"); fOff = fClient->GetPicture("unchecked_t.xpm"); fDisOn = fClient->GetPicture("checked_dis_t.xpm"); fDisOff = fClient->GetPicture("unchecked_dis_t.xpm"); You can change them in $ROOTSYS/icons…

Cheers, Bertrand.

Dear Bertrand

Thanks for the information, so I will have to find another way.
I am actually thinking of adding a TGColorSelector next to the checkbutton. Then I could change the color of the graphs I actually want to toggle with the checkbuttons.
I tried already but the color selectors are not easy to position next to the text buttons.
Furthermore, I would need an array of check buttons.

Cheers,
delos

Sorry I am comming back to my question but is there an object that I can give a color and add it to a TGGroupFrame next to my check buttons?

Cheers,
delos

Hi delos,

You can try with a TGLabel (see for example $(ROOTSYS)/tutorials/gui/guilabels.C)

Cheers, Bertrand.

Ok, I can try thank you.

To position anything next to my checkbutto I need to know where it is. Is there a way to determine the position (relative/absolute) of the button (or any object) within a groupframe?

Cheers,
delos

You should use a horizontal (container) frame, containing the label and its associated check box, and then you add this container frame to the group frame. The layout manager will take care of positioning.

Cheers, Bertrand.

Here is a simple example:[code]#include “TGFrame.h”

void test_group_labels()
{
ULong_t bcolor[10], ycolor;
gClient->GetColorByName(“yellow”, ycolor);
gClient->GetColorByName(“blue”, bcolor[0]);
gClient->GetColorByName(“red”, bcolor[1]);
gClient->GetColorByName(“green”, bcolor[2]);
gClient->GetColorByName(“magenta”, bcolor[3]);
gClient->GetColorByName(“cyan”, bcolor[4]);
gClient->GetColorByName(“black”, bcolor[5]);
TGMainFrame *main = new TGMainFrame(gClient->GetRoot(), 300, 200, kVerticalFrame);
TGGroupFrame *group = new TGGroupFrame(main, “Group”);
group->SetTitlePos(TGGroupFrame::kCenter);
for (int i=1;i<6;i++) {
TGHorizontalFrame *cont = new TGHorizontalFrame(group);
TGLabel *label = new TGLabel(cont, Form(" %d ", i));
label->SetTextColor(ycolor);
label->SetBackgroundColor(bcolor[i]);
TGCheckButton *check = new TGCheckButton(cont, Form(“Example %d”, i));
cont->AddFrame(label, new TGLayoutHints(kLHintsLeft, 2, 2, 2, 2));
cont->AddFrame(check, new TGLayoutHints(kLHintsLeft, 2, 2, 2, 2));
group->AddFrame(cont, new TGLayoutHints(kLHintsCenterX, 2, 2, 2, 2));
}
main->AddFrame(group, new TGLayoutHints(kLHintsExpandX, 2, 2, 2, 2));
main->MapSubwindows();
main->Resize(main->GetDefaultSize());
main->MapWindow();
}[/code]
Cheers, Bertrand.

Works perfect! Great.

Thanks and cheers,
delos

Hi,
depending on what you want to highlight you could set the Foreground (Text)
or Background of the CheckButton directly:

or

instead of putting an extra Label.
Without text the box itself just gets colored edges,
in this case you could put the text into a Label
Otto