Problem: The two LabelEntrys (l1, l2) always shrink to minimal size, but I want them to have the size given to them in the ctor.
If I use kFixedSize, the TableLayout-Manager doesnt work.
My Aim is that the NumberEntry in LabelEntry has a defined size (here 30 digits), the two Buttons have minimal size and
the Lable expands until the LabelEntry has the width given to it in the ctor (here 500 or 600).
[code]
// TableLayoutMacro.C
//Problem: The two LabelEntrys (l1, l2) always shrink to minimal size, but I want them to have the size given to them in the ctor.
//If I use kFixedSize, the TableLayout-Manager doesnt work.
//
//My Aim is that the NumberEntry in LabelEntry has a defined size (here 30 digits), the two Buttons have minimal size and
//the Lable expands until the LabelEntry has the width given to it in the ctor (here 500 or 600).
//(Sometimes this Macro doesnt exit correctly, but i dont know why and how to fix it. But thats not my main Problem)
#include “TGLabel.h”
#include “TGNumberEntry.h”
#include “TGButton.h”
#include “TGTableLayout.h”
#include “TGFrame.h”
class LabelEntry : public TGCompositeFrame{
public:
TGLabel * fLabel;
TGNumberEntry * fNumberEntry;
TGTextButton * fTextButton1, * fTextButton2;
TGTableLayout * tabLayout;
ClassDef(LabelEntry, 0)
public:
LabelEntry(const TGWindow * parent, Int_t Width, Int_t Height); //ctor
};
ClassImp(LabelEntry)
LabelEntry::LabelEntry(const TGWindow * parent, Int_t Width, Int_t Height): TGCompositeFrame(parent, Width, Height){
this->Resize(Width,Height);
tabLayout=new TGTableLayout(this, 2,5, kFALSE);
this->SetLayoutManager(tabLayout);
fLabel = new TGLabel(this, "Label");
fNumberEntry = new TGNumberEntry(this, 0., 30, 1);
fTextButton1 = new TGTextButton(this, "TextButton");
fTextButton2 = new TGTextButton(this, "TextButton2");
this->AddFrame(fLabel, new TGTableLayoutHints(0,1,0,2,
kLHintsExpandX|kLHintsExpandY
| kLHintsShrinkX|kLHintsShrinkY |
kLHintsCenterX|kLHintsCenterY
| kLHintsFillX|kLHintsFillY
,1,1,1,1));
this->AddFrame(fNumberEntry, new TGTableLayoutHints(1,2,0,2,
kLHintsExpandX|kLHintsExpandY
| kLHintsShrinkX|kLHintsShrinkY |
kLHintsCenterX|kLHintsCenterY
| kLHintsFillX|kLHintsFillY
,1,1,1,1));
this->AddFrame(fTextButton1, new TGTableLayoutHints(2,3,0,1,
kLHintsExpandX|kLHintsExpandY
| kLHintsShrinkX|kLHintsShrinkY |
kLHintsCenterX|kLHintsCenterY
| kLHintsFillX|kLHintsFillY
,1,1,1,1));
this->AddFrame(fTextButton2, new TGTableLayoutHints(2,3,1,2,
kLHintsExpandX|kLHintsExpandY
| kLHintsShrinkX|kLHintsShrinkY |
kLHintsCenterX|kLHintsCenterY
| kLHintsFillX|kLHintsFillY
,1,1,1,1));
//this->ChangeOptions(this->GetOptions() | kFixedSize); // <= why doesnt it work?
}
void start(){
TGMainFrame * w = new TGMainFrame (gClient->GetRoot(), 800, 800);
LabelEntry *l1, *l2;
l1= new LabelEntry(w, 500,60);
l2= new LabelEntry(w, 600, 70);
w->AddFrame(l1);
w->AddFrame(l2);
w->SetWindowName("Example Macro");
w->MapSubwindows();
w->Resize();
w->Resize(800, 800);
w->MapWindow();
}[/code]
Thanks for the Help!!
Maxi