TGTableLayout

Hi All,

Where it is possible to find an example of the TGTableLayout using.
My code is crushed when the next lines were added

fCFEff = fTab->AddTab(“Efficiency”);
fCFEff->SetLayoutManager(new TGVerticalLayout(fCFEff));

fGFeffinp = new TGGroupFrame(fCFEff,“Input”);
fGFeffinp->SetLayoutManager(new TGTableLayout(fGFeffinp,2,3,kFALSE,5,kLHintsNormal));

… some lines with initialization of TGLabel *fLefftype,…, TGTextButton *fTBefffile

fGFeffinp->AddFrame(fLefftype, new TGTableLayoutHints(0,0,0,0));
fGFeffinp->AddFrame(fCBefftype, new TGTableLayoutHints(1,1,0,0));
fGFeffinp->AddFrame(fLefffile, new TGTableLayoutHints(0,0,1,1));
fGFeffinp->AddFrame(fTEefffile, new TGTableLayoutHints(1,1,1,1));
fGFeffinp->AddFrame(fTBefffile, new TGTableLayoutHints(2,2,1,1));

If I commented last 5 lines then other part of code works.
I wanted to have:
line-1: TGLabel, TGComboBox
line-2: TGLabel, TGTextEntry, TGTextButton

Thanks in advance,
Andrei

Hi Andrei,

I will check why your example causes a problem next week. Meanwhile you can use two horizontal composite frames nested in a vertical one for your design. Just put the TGLabel and TGComboBox into the first horizontal frame; the TGLabel, TGTextEntry, and TGTextButton into the second one, and use as a parent of both horizontal frames a vertical frame. If you use the classes we have: TGHorizontalFrame and TGVerticalFrame, you do not need to set a layout manager for them.

Cheers, Ilka

Hi Ilka,

The using of TGHorizontalFrame class has two problems for me.

  1. The nex TGGroupFrame must have 6 by 6 table and some ceils in the middle of the table must be free.
  2. I want that two TGTextEntry will be even by the left border. How to make this using two different TGHorizontalFrame?

I tried to use TGMatrixLayout. It works but arose another questions.
Is it possible to direct the width of ceils in the matriix? Automatically it creates ceils having the equal width using the lagest one.
How to skip some ceils? I use additional class TGLabel witout text to fill these ceils. Is it possible to go witout the introducing of additional classes.

Best regards,
Andrei

Hi Andrei,

Try this way :

fGFeffinp->AddFrame(fLefftype, new TGTableLayoutHints(0,1,0,1));
fGFeffinp->AddFrame(fCBefftype, new TGTableLayoutHints(1,2,0,1));
fGFeffinp->AddFrame(fLefffile, new TGTableLayoutHints(0,1,1,2));
fGFeffinp->AddFrame(fTEefffile, new TGTableLayoutHints(1,2,1,2));
fGFeffinp->AddFrame(fTBefffile, new TGTableLayoutHints(2,3,1,2));

Cheers,
Bertrand.

Hi Andrei,

I see Bertrand has fixed your problem. I will answer your question about how to allign on the left the widgets in use - you need to play with the amount of left, right padding of layout hints.

Cheers, Ilka

Hi Ilka,

The Bertrand’s example did not help. If I use TGTableLayout the code does not work. When I change TGTableLayout on TGMatrixLayout and exclude TGTableLayoutHints from AddFrame, the code works but sizes and positions of ceils are not suitable to me.

Sincerely Yours,
Andrei

Hi Andrei,

Please confirm that you want the following layout of your design before I write a macro to implement it:

| Label: |Combo box | | Label: |Text entry | Button |
Thank you, Ilka

Hi Ilka,

You are absolutely correct. That is what I want to have in the TGGroupFrame. I do not use macros in this project. I do it under Visual Studio Net. The discussed Frame is at the end of the next series of creating frames.
TGTransientFrame->TGHorizontalFrame->TGTab->TGCompositeFrame->TGGroupFrame
TGTransientFrame *fFrame is a dialog frame creating from the main window and the code stop at the fFrame->Resize(fFrame->GetDefaultSize()). It stops here only when TGTableLayout is included.

Best regards,
Andrei

Hi Andrei,

Please find as an example the macro gui1.C. It can be interpreted and compiled.

Cheers, Ilka

Hi Ilka,

The problem is in the width of TGLabel. You used the same number of characters in the two labels. Change the second label as
TGLabel *label2 = new TGLabel(hframe2, “Label_1002:”);
and you will see my problem. In principal, i can add some blanks in the first label to have the same width of two labels. I do not understand why the command (which I added to your example)
label1->Resize(label2->GetWidth(), label1->GetDefaultHeight());
does not work.

Best regards,
Andrei

Hi Andrei,

I was thinking to provide the different labels to show you that case, but in fact, I forgot to do it in my macro. Please find it in the attached macro where the labels are different. To alling the combo box and the text field in the horizontal frames I have added the necessary space in the layout hints adding the ‘Label_1’ to its container frame (see the code line 33).

Best regards, Ilka

Hi Ilka,

Thanks for your long help. I saw your last example. Unfortunately, it is not easy to calculate each time the shift of labels by hand. Probably, I will use the same number of characters in labels using additional blank characters.

Best regards,
Andrei