#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)
{
TGVerticalFrame *hframe1 = new TGVerticalFrame(this, 170, 50, kFixedWidth);
test = new TGTextButton(hframe1, "&Test ");
hframe1->AddFrame(test, new TGLayoutHints(kLHintsTop | kLHintsLeft | kLHintsExpandX,2,0,2,2));
AddFrame(hframe1, new TGLayoutHints(kLHintsCenterX, 2, 2, 5, 1));
TGCompositeFrame *cframe1 = new TGCompositeFrame(this, 170, 20, kHorizontalFrame | kFixedWidth);
draw = new TGTextButton(cframe1, "&Draw");
cframe1->AddFrame(draw, new TGLayoutHints(kLHintsTop | kLHintsLeft | kLHintsExpandX,2,2,2,2));
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));
TGCompositeFrame *cframe2 = new TGCompositeFrame(this, 170, 20, kHorizontalFrame | kFixedWidth);
ok = new TGTextButton(cframe2, "OK");
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");
SetWMSizeHints(200, 80, 320, 320, 1, 1);
MapSubwindows();
Resize(GetDefaultSize());
MapWindow();
}
MyMainFrame::~MyMainFrame()
{
Cleanup();
}
void buttonsLayout()
{
new MyMainFrame(gClient->GetRoot(), 350, 80);
}
|
|