Re: TGComboBox for selecting colors

Fons Rademakers (rdm@pcsalo.cern.ch)
Mon, 24 Aug 1998 21:43:05 +0200 (METDST)


Hi Rutger,

why not use the example of guitest? The canvas with the color tiles?
Instead of frames you could use buttons (for the selection effect).

Cheers, Fons.

>
>
> Hi ROOTers (Fons),
>
> I need a 'widget' or sort of ListBox to select a color. I was thinking of
> using a TGComboBox for this, but don't succeed to get it working.
>
> By idea is the following:
>
> Instead of adding 'text' as 'entry' via
>
> TGComboBox::AddEntry(char *s, Int_t id);
>
> I add a TGLBEntry with
>
> TGComboBox* fComboBox;
> <....>
> fComboBox->AddEntry(lbe, lhints);
>
> where
>
> lbe = new TGLBEntry(fComboBox->GetListBox()->GetContainer, id,
> kHorizontalFrame, entryColor);
> lhints = new TGLayoutHints(kLHintsExpandX | kLHintsTop);
>
> where 'entryColor' is the color I want for the entry.
>
> This seems not to work at all (the TGPopupComboBox is empty => no
> entries).
>
> This is the first part I don't understand. It might be that this is
> because of the comment in the TGListBox class description (i.e. 'Currently
> entries are simple text strings (TGTextLBEntry)'). But it seems strange
> to me that I need to use a TGTextLBEntry, instead of the base class
> TGLBEntry (which is used in the TGListBox!!!) if I don't want the extra
> functionality of adding text.
>
> But to continue I tried using a TGTextLBEntry which I then give the
> required entryColor as background color. now I use:
>
> lbe = new TGTextLBEntry(fComboBox->GetListBox()->GetContainer(),
> new TGString("don't want this string"), id,
> theGC,
> theFont,
> kHorizontalFrame,
> entryColor),
>
> where theGC and theFont are GC and FontStruct defined as mentioned in
> guitest.cxx.
>
>
> What happens is that I indead get the entry in the TGComboBox (I infact
> add more TGTextLBEnties with different color) with a color (not the one I
> want, but that's for later concern.) But when I select an entry the
> 'selected entry' does not have the 'right' background color anymore.
> Looking into the source code it seems that this is caused by:
>
> TGTextLBEntry::Update(TGLBEntry *e)
> { SetText(new TGString(((TGTextLBEntry *)e)->GetText())); }
>
> which only updates the text...
>
>
> This seems not to bring me any further. My question(s);
> - am I on the right way to implement the 'widget' that I want (i.e. a
> color selector)?
> - Did anybody implement something like that already (in a different way?)
> - any suggestions (Fons?)
>
>
> Thanks, and keep up the good work,
>
> Rutger van der Eijk.
>

-- 
Org:    CERN, European Laboratory for Particle Physics.
Mail:   1211 Geneve 23, Switzerland          Phone: +41 22 7679248
E-Mail: Fons.Rademakers@cern.ch              Fax:   +41 22 7677910