#include "TGButton.h" #include "TGSplitter.h" #include "TGTextEntry.h" class TwoColumnEntry { private: TGMainFrame *fMain; TGLayoutHints *fLo; TGVerticalFrame *fV1; TGVerticalFrame *fV2; public: TwoColumnEntry(const char *col1 = "column1", const char *col2 = "column2"); ~TwoColumnEntry() { delete fMain; } void AddRow(const char *e1 = "", const char *e2 = ""); void Show(); }; //______________________________________________________________________________ TwoColumnEntry::TwoColumnEntry(const char *col1, const char *col2) { // fLo = new TGLayoutHints(kLHintsExpandX | kLHintsExpandY); TGLayoutHints *lo1 = new TGLayoutHints(kLHintsLeft | kLHintsExpandY); TGLayoutHints *lo2 = new TGLayoutHints(kLHintsRight | kLHintsExpandX | kLHintsExpandY); fMain = new TGMainFrame(gClient->GetRoot(), 1, 1, kHorizontalFrame); TGCompositeFrame *h = new TGCompositeFrame(fMain, 100, 100, kHorizontalFrame | kRaisedFrame); fMain->AddFrame(h, fLo); fV1 = new TGVerticalFrame(h, 1, 1, kFixedWidth); h->AddFrame(fV1, lo1); TGVSplitter *splitter = new TGVSplitter(h); splitter->SetFrame(fV1, kTRUE); h->AddFrame(splitter, lo1); TGTextButton *b = new TGTextButton(fV1, col1); fV1->AddFrame(b, fLo); fV1->Resize(b->GetDefaultSize()); fV2 = new TGVerticalFrame(h, 1, 1); h->AddFrame(fV2, lo2); b = new TGTextButton(fV2, col2); fV2->AddFrame(b, fLo); h->MapSubwindows(); fMain->Resize(); } //______________________________________________________________________________ void TwoColumnEntry::AddRow(const char *e1, const char *e2) { // TGTextEntry *te = new TGTextEntry(fV1, e1); fV1->AddFrame(te, fLo); te = new TGTextEntry(fV2, e2); fV2->AddFrame(te, fLo); fMain->Resize(); } //______________________________________________________________________________ void TwoColumnEntry::Show() { // fMain->MapSubwindows(); fMain->MapRaised(); } //______________________________________________________________________________ void twoColumn() { // TwoColumnEntry *te = new TwoColumnEntry(); for (int i = 1; i<10; i++) { te->AddRow(Form(" row%d", i)); } te->Show(); }