// // Author: Ilka Antcheva 1/12/2006 // This macro gives an example of different buttons' layout. // To run it do either: // .x buttonsLayout.C // .x buttonsLayout.C++ #include #include class MyMainFrame : public TGMainFrame { private: TGTextButton *test, *draw, *help, *ok, *cancel, *exit; public: MyMainFrame(const TGWindow *p, UInt_t w, UInt_t h); virtual ~MyMainFrame(); ClassDef(MyMainFrame, 0) }; MyMainFrame::MyMainFrame(const TGWindow *p, UInt_t w, UInt_t h) : TGMainFrame(p, w, h) { int padding=2; TGCompositeFrame* buttonFrame1 = new TGCompositeFrame(this, 10, 10, kVerticalFrame | kFixedWidth); TGTextButton* button1 = new TGTextButton(buttonFrame1, "Button 1"); buttonFrame1->AddFrame(button1, new TGLayoutHints(kLHintsExpandX, padding, padding, padding, padding)); AddFrame(buttonFrame1, new TGLayoutHints(kLHintsExpandX, padding, padding, padding, padding)); TGTextButton* button2 = new TGTextButton(buttonFrame1, "Button 2"); buttonFrame1->AddFrame(button2, new TGLayoutHints(kLHintsExpandX, padding, padding, padding, padding)); TGTextButton* button3 = new TGTextButton(buttonFrame1, "Button 3"); buttonFrame1->AddFrame(button3, new TGLayoutHints(kLHintsExpandX, padding, padding, padding, padding)); TGCompositeFrame* buttonFrame2 = new TGCompositeFrame(this, 10, 10, kHorizontalFrame | kFixedWidth); TGTextButton* quitButton = new TGTextButton(this, "Quit"); buttonFrame2->AddFrame(quitButton, new TGLayoutHints(kLHintsExpandX, padding, padding, padding, padding)); TGTextButton* goButton = new TGTextButton(this, "Go"); buttonFrame2->AddFrame(goButton, new TGLayoutHints(kLHintsExpandX, padding, padding, padding, padding)); AddFrame(buttonFrame2, new TGLayoutHints(kLHintsExpandX, padding, padding, padding, padding)); SetWindowName("Buttons' Layout"); // gives min/max window size + a step of x,y incrementing between the given sizes SetWMSizeHints(200, 80, 320, 320, 1, 1); MapSubwindows(); // important for layout algorithm Resize(GetDefaultSize()); MapWindow(); } MyMainFrame::~MyMainFrame() { // Clean up all widgets, frames and layouthints that were used Cleanup(); } void simpleExample() { // Popup the GUI... new MyMainFrame(gClient->GetRoot(), 350, 80); }