#include #include #include #include using namespace std; class testGui4 : public TObject { protected: //main frame TGMainFrame *mainFrame; //composite frame will hold my TGTextButton and TGListBox TGCompositeFrame *topFrame; TGTextButton *quitButton; TGListBox *listBox; public: testGui4(const TGWindow *p, UInt_t w, UInt_t h); virtual ~testGui4(){}; void ProcessedEvent(Event_t*); ClassDef(testGui4,0); }; ClassImp(testGui4); testGui4::testGui4(const TGWindow *p, UInt_t w, UInt_t h) { mainFrame = new TGMainFrame(p, w, h); topFrame = new TGCompositeFrame(mainFrame, 10, 10, kHorizontalFrame); // make the list box and put it into the top frame listBox = new TGListBox(topFrame); topFrame->AddFrame(listBox, new TGLayoutHints(kLHintsExpandX,2,2,2,2)); //give the box a height of 300pixels and width 700 listBox->Resize(700,300); //make the button and put it into the top frame quitButton = new TGTextButton(topFrame, "Quit"); topFrame->AddFrame(quitButton, new TGLayoutHints(kLHintsLeft|kLHintsCenterY,2,2,2,2)); // this line is needed to allow to specify a fixed size (and not let the layout manager compute the size) quitButton->ChangeOptions(quitButton->GetOptions() | kFixedSize); quitButton->Resize(500, 100); // add the composite frame to the main frame // use expand X and Y layout hints to enable automatic resizing mainFrame->AddFrame(topFrame, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY, 2, 2, 2, 2)); mainFrame->Connect("ProcessedEvent(Event_t*)", "testGui4", this, "ProcessedEvent(Event_t*)"); mainFrame->SetWindowName("Test Program Fixed Widths"); mainFrame->MapSubwindows(); mainFrame->MoveResize(300, 300, 1000, 500); mainFrame->MapWindow(); } void testGui4::ProcessedEvent(Event_t *event) { // handle the kConfigureNotify events only if (event->fType != kConfigureNotify) return; quitButton->Resize(event->fWidth/4, event->fHeight/10); mainFrame->Layout(); } void testTheGui4() { new testGui4(gClient->GetRoot(), 1, 1); }