How to make TGTextEntry to resise

Hi All,
I have a TGTextEntry and a TGListBox in my application. How do I make them to resise automaticaly when the parent frame is resised?

kLHintsExpandX layout hint makes TGTextEntry (orTGListBox) to expand to the sise of the parent frame, but then when i choose smaller width for the parent frame TGTextEntry (orTGListBox) doesn’t change its width.

thanks,
-Aram.

Hi Aram,

In addition to kLHintsExpandX you should create the TGTextEntry widget with the option kFitWidth (i.e. use as the option parameter in the TGTextEntry constructor the following frame
option:

kSunkenFrame | kDoubleBorder | kOwnBackground | kFitWidth

Best regards, Ilka

Hello Ilka and others,

I tried to use kFitWidth, but it doesnt seem to work :confused: … maybe I am doing something worng. Here is a macro that reproduces my problem.
there is a TGVSplitter on the right side of the TGShutter frame. If you move it to the right TGTextEnry will increase its width, but then when you reduce the width of the shutter frame the textentry frame doesnt change its width.

                                                 -Aram.

//-----------------------
class TestTextEntry
{
TGMainFrame* fMain;

TGVSplitter* vSplitter;
TGTextEntry* fTxt;
TGHorizontalFrame* hframe;
TGCompositeFrame* cvframe1;
TGCompositeFrame* cvframe2;

public:

     TestTextEntry(const TGWindow* p, UInt_t w, UInt_t h);
     virtual ~TestTextEntry();

};

TestTextEntry::TestTextEntry(const TGWindow* p, UInt_t w, UInt_t h)
{
fMain = new TGMainFrame(p, w, h);

hframe = new TGHorizontalFrame(fMain, 800, 600);
fMain->AddFrame(hframe, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY, 1, 1, 1, 1));

cvframe1 = new TGCompositeFrame(hframe, 400, 600, kVerticalFrame | kFixedWidth);
hframe->AddFrame(cvframe1, new TGLayoutHints(kLHintsExpandY, 1, 1, 1, 1));

vSplitter = new TGVSplitter(hframe);
vSplitter->SetFrame(cvframe1, kTRUE);
hframe->AddFrame(vSplitter, new TGLayoutHints(kLHintsLeft | kLHintsExpandY));

fShutter= new TGShutter(cvframe1, kSunkenFrame /| kFitWidth/);
cvframe1->AddFrame(fShutter, new TGLayoutHints(kLHintsExpandY | kLHintsExpandX, 1, 1, 1, 1));
fItem = new TGShutterItem(fShutter, new TGHotString(“Shutter Item”), 1/, kFitWidth/);
TGCompositeFrame *container1 = (TGCompositeFrame *) fItem->GetContainer();
fShutter->AddItem(fItem);

fTxt = new TGTextEntry(container1, fBuff = new TGTextBuffer(100), kFitWidth);
fL = new TGLayoutHints(kLHintsTop | kLHintsLeft | kLHintsExpandX, 10, 1, 1, 18 );
container1->AddFrame(fTxt, fL);

bt_exit1 = new TGTextButton(container1, “&Exit”,“gApplication->Terminate(0)”);
container1->AddFrame(bt_exit1, new TGLayoutHints(kLHintsBottom | kLHintsCenterX | kLHintsExpandX, 3, 3, 3, 3));

cvframe2 = new TGCompositeFrame(hframe, 400, 600, kVerticalFrame);
hframe->AddFrame(cvframe2, new TGLayoutHints(kLHintsTop | kLHintsRight | kLHintsExpandX | kLHintsExpandY , 5, 5, 5, 5));

bt_exit = new TGTextButton(cvframe2, “&Exit”,“gApplication->Terminate(0)”);
cvframe2->AddFrame(bt_exit, new TGLayoutHints(kLHintsBottom | kLHintsCenterX | kLHintsExpandX, 3, 3, 3, 3));

fMain->SetWindowName(“title”);

fMain->MapSubwindows();

fMain->Resize(fMain->GetDefaultSize());

//Map main frame
fMain->MapWindow();
}

TestTextEntry::~TestTextEntry()
{
fMain->Cleanup();
delete fMain;
}

void testtextentry()
{
new TestTextEntry(gClient->GetRoot(), 800, 600);
}

//-----------------------------------------

Hi Aram,

What I see from your code is that you do not make difference between lauout hints options and frame type options. Please read the chapter ‘Writting a GUI’ of ROOT User’s Guide:
ftp://root.cern.ch/root/doc/chapter21.pdf
and see the frame type options on page 369 and layout hints on page 373.
Please see also the vertical splitter example on page 394.

This information will help you to solve the problem.

Best regards, Ilka

Hi Ilka,

Thanks for the hints, I just edited my prvious post.

in particular the following lines:

fTxt = new TGTextEntry(container1, fBuff = new TGTextBuffer(100), kFitWidth);
fL = new TGLayoutHints(kLHintsTop | kLHintsLeft | kLHintsExpandX, 10, 1, 1, 18 );
container1->AddFrame(fTxt, fL);

but I still have the same problem,

                                    -Aram.

Hi Aram,

The text entry widget you put in the shutter’s container. You should use somehow this container as a left resized frame of the vertical splitter or you need to adjust its width with the left resized frame of the splitter.

We have long weekend this week (starting from today) and I can have a look on your code next week.

Best regards, Ilka

Hi Ilka,

the thing is if I put only "TGTextButton"s in the shutter’s container, there is no any problem. its only TGTextEntry and and TGListBox that are problematic.

              -Aram.