How to fixed size of text buttons

Hi All,

I create two text buttons in the dialog window using the next lines of code.

fHD = new TGHorizontalFrame(fMain,700,30,kChildFrame | kFixedHeight);
fMain->AddFrame(fHD,new TGLayoutHints(kLHintsLeft | kLHintsBottom | kLHintsExpandX));
fTBok = new TGTextButton(fHD,“Ok”);
fTBcancel = new TGTextButton(fHD,“Cancel”);
fHD->AddFrame(fTBcancel, new TGLayoutHints(kLHintsTop | kLHintsRight ,2,0,2,2));
fHD->AddFrame(fTBok, new TGLayoutHints(kLHintsTop | kLHintsRight ,2,0,2,2));

As result I get two buttons having different width. If I add next two lines then the never is changed.

fTBok->ChangeOptions((fTBok->GetOptions()) | kFixedSize);
fTBok->SetWidth(60);

How to fixed the size of text buttons?

Thanks in advance,
Andrei

Hi Andrei,

The way to do that is to have the parent frame has a fixed width, and the children are added with kLHintsExpandX layout hints, i.e. your code will work if you change it the following way:

TGHorizontalFrame *fHD = new TGHorizontalFrame(fMain,700,30,kChildFrame | kFixedWidth); fMain->AddFrame(fHD,new TGLayoutHints(kLHintsLeft | kLHintsBottom | kLHintsExpandX)); fTBok = new TGTextButton(fHD,"Ok"); fTBcancel = new TGTextButton(fHD,"Cancel"); fHD->AddFrame(fTBcancel, new TGLayoutHints(kLHintsExpandX ,2,0,2,2)); fHD->AddFrame(fTBok, new TGLayoutHints(kLHintsExpandX ,2,0,2,2));
Cheers, Ilka

Hi Ilka,

Your example creates two text buttons having summary width that is equal to the fHD width. I wanted to have two small buttons placed in the right bottom corner of the frame. In pricipal, I can divide fHD frame on two frames and put all text buttons in the new right frame. But, is it possible to exclude these additional frames?

Best regards,
Andrei

Hi Andrei,

Yes, you can exclude the additional farme playing with the layout hints. In your case the code should be:

TGHorizontalFrame *fHD = new TGHorizontalFrame(fMain,100,30,kChildFrame | kFixedWidth); fMain->AddFrame(fHD,new TGLayoutHints(kLHintsRight, 5,5,5,5)); fTBok = new TGTextButton(fHD,"Ok"); fTBcancel = new TGTextButton(fHD,"Cancel"); fHD->AddFrame(fTBcancel, new TGLayoutHints(kLHintsExpandX ,2,0,2,2)); fHD->AddFrame(fTBok, new TGLayoutHints(kLHintsExpandX ,2,0,2,2));
Cheers, Ilka

Hi Ilka,

Thanks. Your last example works as I wanted.

Best regards,
Andrei