Hi.I’m making a GUI in order to produce a output file. I would like to create more columns of TGNumberEntry and for each column a different number of TGNumberEntry.
i try in this way but it puts the two columns one below the other but i want them side by side
[code]#include
#include <stdlib.h>
class MyMainFrame : public TGMainFrame {
private:
TGCompositeFrame *fHor1,*f2,*f3,*c1,*c2,*exitandsave,*s1;
TGTextButton *fExit,*Save;
TGGroupFrame *fGframe;
TGNumberEntry *fNumber,*fNumber2,*fNumber3,*fNumberc2;
TGLabel *fLabel,*fLabel2,*fLabel3,*fLabelc2;
public:
MyMainFrame(const TGWindow *p, UInt_t w, UInt_t h);
virtual ~MyMainFrame();
void Save1();
ClassDef(MyMainFrame, 0)
};
MyMainFrame::MyMainFrame(const TGWindow *p, UInt_t w, UInt_t h)
: TGMainFrame(p, w, h)
{
std::ofstream ofs;
ofs.open (“test.inp”);
///////////////////////////
c2=new TGVerticalFrame(this,60,400);
c1=new TGVerticalFrame(this,60,400);
//c2=new TGHVerticalFrame(this,60,400);
fHor1 = new TGHorizontalFrame(c1, 150, 20, kFixedWidth);
f2=new TGHorizontalFrame(c1, 150, 20, kFixedWidth);
f3=new TGHorizontalFrame(c1, 150, 20, kFixedWidth);
s1=new TGHorizontalFrame(c2, 150, 20, kFixedWidth);
exitandsave=new TGHorizontalFrame(c1, 150, 20, kFixedWidth);
////////////////exit and save
fExit = new TGTextButton(exitandsave, “&Exit”, “gApplication->Terminate(0)”);
Save= new TGTextButton(exitandsave,"&Salva");
Save->Connect(“Clicked()”,“MyMainFrame”,this,“Save1()”);
exitandsave->AddFrame(Save, new TGLayoutHints(kLHintsBottom| kLHintsLeft ,4, 4, 4, 4));
exitandsave->AddFrame(fExit, new TGLayoutHints(kLHintsBottom | kLHintsLeft , 4, 4, 4, 4));
c1->AddFrame(exitandsave,new TGLayoutHints(kLHintsBottom | kLHintsRight, 5, 5, 5, 5));
////////////////////////////
fNumber = new TGNumberEntry(fHor1, 0, 9,999, TGNumberFormat::kNESInteger,
TGNumberFormat::kNEANonNegative,
TGNumberFormat::kNELLimitMinMax,
0, 99999);
fHor1->AddFrame(fNumber, new TGLayoutHints(kLHintsTop | kLHintsLeft, 5, 5, 5, 5));
fLabel = new TGLabel(fHor1, “No inp.”);
fHor1->AddFrame(fLabel, new TGLayoutHints(kLHintsTop | kLHintsRight, 5, 5, 5, 5));
c1->AddFrame(fHor1,new TGLayoutHints(kLHintsBottom | kLHintsRight, 2, 2, 5, 1));
///////////////////////
fNumber2 = new TGNumberEntry(f2, 0, 9,999, TGNumberFormat::kNESInteger,
TGNumberFormat::kNEANonNegative,
TGNumberFormat::kNELLimitMinMax,
0, 99999);
f2->AddFrame(fNumber2, new TGLayoutHints(kLHintsTop | kLHintsLeft, 5, 5, 5, 5));
fLabel2 = new TGLabel(f2, “2222222”);
f2->AddFrame(fLabel2, new TGLayoutHints(kLHintsTop | kLHintsRight, 5, 5, 5, 5));
c1->AddFrame(f2,new TGLayoutHints(kLHintsBottom | kLHintsRight, 2, 2, 5, 1));
///////////////////
fNumber3 = new TGNumberEntry(f3, 0, 9,999, TGNumberFormat::kNESInteger,
TGNumberFormat::kNEANonNegative,
TGNumberFormat::kNELLimitMinMax,
0, 99999);
f3->AddFrame(fNumber3, new TGLayoutHints(kLHintsTop | kLHintsLeft, 5, 5, 5, 5));
fLabel3 = new TGLabel(f3, “2222222”);
f3->AddFrame(fLabel3, new TGLayoutHints(kLHintsTop | kLHintsRight, 5, 5, 5, 5));
c1->AddFrame(f3,new TGLayoutHints(kLHintsBottom | kLHintsRight, 2, 2, 5, 1));
//(fNumber->GetNumberEntry())->Connect(“ReturnPressed()”, “MyMainFrame”, this,“DoSetlabel()”);
//fGframe = new TGGroupFrame(this, “Value”);
//////////////metti la prima colonna
AddFrame(c1,new TGLayoutHints(kLHintsBottom | kLHintsLeft, 5, 5, 5, 5));
///////////////////// seconda colonna
fNumberc2 = new TGNumberEntry(s1, 0, 9,999, TGNumberFormat::kNESInteger,
TGNumberFormat::kNEANonNegative,
TGNumberFormat::kNELLimitMinMax,
0, 99999);
s1->AddFrame(fNumberc2, new TGLayoutHints(kLHintsTop | kLHintsLeft, 5, 5, 5, 5));
fLabelc2 = new TGLabel(s1, “No inp.”);
s1->AddFrame(fLabelc2, new TGLayoutHints(kLHintsTop | kLHintsRight, 5, 5, 5, 5));
c2->AddFrame(s1,new TGLayoutHints(kLHintsBottom | kLHintsRight, 5, 5, 5, 5));
////////////////////////// fine seconda colonna
AddFrame(c2,new TGLayoutHints(kLHintsBottom | kLHintsRight, 5, 5, 5, 5));
/////////////////
SetCleanup(kDeepCleanup);
SetWindowName(“Number Entry”);
MapSubwindows();
Resize(GetDefaultSize());
MapWindow();
}
MyMainFrame::~MyMainFrame()
{
// Destructor.
Cleanup();
}
void MyMainFrame::Save1()
{
// Slot method connected to the ValueSet(Long_t) signal.
// It displays the value set in TGNumberEntry widget.
std::ofstream ofs;
ofs.open (“test.inp”);
ofs<GetNumberEntry()->GetIntNumber()<<","<GetNumberEntry()->GetIntNumber()<<","
<GetNumberEntry()->GetIntNumber()<<endl;
// Parent frame Layout() method will redraw the label showing the new value.
//fGframe->Layout();
}
void esempio()
{
new MyMainFrame(gClient->GetRoot(), 200, 200);
}
[/code]
thank you