buttongroupState.C: A simple example that shows the enabled and disabled state | Graphics User Interface | calendar.C: This macro gives an example of how to use html widget |
// // 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 <TGClient.h> #include <TGButton.h> 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) { // Create a container frames containing buttons // one button is resized up to the parent width. Note! this width should be fixed! TGVerticalFrame *hframe1 = new TGVerticalFrame(this, 170, 50, kFixedWidth); test = new TGTextButton(hframe1, "&Test "); // to take whole space we need to use kLHintsExpandX layout hints hframe1->AddFrame(test, new TGLayoutHints(kLHintsTop | kLHintsLeft | kLHintsExpandX,2,0,2,2)); AddFrame(hframe1, new TGLayoutHints(kLHintsCenterX, 2, 2, 5, 1)); // two buttons are resized up to the parent width. Note! this width should be fixed! TGCompositeFrame *cframe1 = new TGCompositeFrame(this, 170, 20, kHorizontalFrame | kFixedWidth); draw = new TGTextButton(cframe1, "&Draw"); // to share whole parent space we need to use kLHintsExpandX layout hints cframe1->AddFrame(draw, new TGLayoutHints(kLHintsTop | kLHintsLeft | kLHintsExpandX,2,2,2,2)); // button background will be set to yellow ULong_t yellow; gClient->GetColorByName("yellow", yellow); help = new TGTextButton(cframe1, "&Help"); help->ChangeBackground(yellow); cframe1->AddFrame(help, new TGLayoutHints(kLHintsTop | kLHintsLeft | kLHintsExpandX,2,2,2,2)); AddFrame(cframe1, new TGLayoutHints(kLHintsCenterX, 2, 2, 5, 1)); // three buttons are resized up to the parent width. Note! this width should be fixed! TGCompositeFrame *cframe2 = new TGCompositeFrame(this, 170, 20, kHorizontalFrame | kFixedWidth); ok = new TGTextButton(cframe2, "OK"); // to share whole parent space we need to use kLHintsExpandX layout hints cframe2->AddFrame(ok, new TGLayoutHints(kLHintsTop | kLHintsLeft | kLHintsExpandX,3,2,2,2)); cancel = new TGTextButton(cframe2, "Cancel "); cframe2->AddFrame(cancel, new TGLayoutHints(kLHintsTop | kLHintsLeft | kLHintsExpandX,3,2,2,2)); exit = new TGTextButton(cframe2, "&Exit ","gApplication->Terminate(0)"); cframe2->AddFrame(exit, new TGLayoutHints(kLHintsTop | kLHintsLeft | kLHintsExpandX,2,0,2,2)); AddFrame(cframe2, new TGLayoutHints(kLHintsCenterX, 2, 2, 5, 1)); 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 buttonsLayout() { // Popup the GUI... new MyMainFrame(gClient->GetRoot(), 350, 80); } buttonsLayout.C:1 buttonsLayout.C:2 buttonsLayout.C:3 buttonsLayout.C:4 buttonsLayout.C:5 buttonsLayout.C:6 buttonsLayout.C:7 buttonsLayout.C:8 buttonsLayout.C:9 buttonsLayout.C:10 buttonsLayout.C:11 buttonsLayout.C:12 buttonsLayout.C:13 buttonsLayout.C:14 buttonsLayout.C:15 buttonsLayout.C:16 buttonsLayout.C:17 buttonsLayout.C:18 buttonsLayout.C:19 buttonsLayout.C:20 buttonsLayout.C:21 buttonsLayout.C:22 buttonsLayout.C:23 buttonsLayout.C:24 buttonsLayout.C:25 buttonsLayout.C:26 buttonsLayout.C:27 buttonsLayout.C:28 buttonsLayout.C:29 buttonsLayout.C:30 buttonsLayout.C:31 buttonsLayout.C:32 buttonsLayout.C:33 buttonsLayout.C:34 buttonsLayout.C:35 buttonsLayout.C:36 buttonsLayout.C:37 buttonsLayout.C:38 buttonsLayout.C:39 buttonsLayout.C:40 buttonsLayout.C:41 buttonsLayout.C:42 buttonsLayout.C:43 buttonsLayout.C:44 buttonsLayout.C:45 buttonsLayout.C:46 buttonsLayout.C:47 buttonsLayout.C:48 buttonsLayout.C:49 buttonsLayout.C:50 buttonsLayout.C:51 buttonsLayout.C:52 buttonsLayout.C:53 buttonsLayout.C:54 buttonsLayout.C:55 buttonsLayout.C:56 buttonsLayout.C:57 buttonsLayout.C:58 buttonsLayout.C:59 buttonsLayout.C:60 buttonsLayout.C:61 buttonsLayout.C:62 buttonsLayout.C:63 buttonsLayout.C:64 buttonsLayout.C:65 buttonsLayout.C:66 buttonsLayout.C:67 buttonsLayout.C:68 buttonsLayout.C:69 buttonsLayout.C:70 buttonsLayout.C:71 buttonsLayout.C:72 buttonsLayout.C:73 buttonsLayout.C:74 buttonsLayout.C:75 buttonsLayout.C:76 buttonsLayout.C:77 buttonsLayout.C:78 buttonsLayout.C:79 buttonsLayout.C:80 buttonsLayout.C:81 buttonsLayout.C:82 buttonsLayout.C:83 buttonsLayout.C:84 buttonsLayout.C:85 buttonsLayout.C:86 buttonsLayout.C:87 |
|