00001
00002
00003
00004
00005
00006
00007
00008
00009 #include <TGClient.h>
00010 #include <TGButton.h>
00011 #include <TGLabel.h>
00012 #include <TGFrame.h>
00013 #include <TGLayout.h>
00014 #include <TGSplitter.h>
00015
00016
00017 class MyMainFrame : public TGMainFrame {
00018
00019 public:
00020 MyMainFrame(const TGWindow *p, UInt_t w, UInt_t h);
00021 virtual ~MyMainFrame();
00022 void DoSave();
00023 void CloseWindow();
00024
00025 ClassDef(MyMainFrame, 0)
00026 };
00027
00028
00029 void MyMainFrame::DoSave()
00030 {
00031 Printf("Save in progress...");
00032 SaveSource("","");
00033 }
00034
00035
00036 MyMainFrame::MyMainFrame(const TGWindow *p, UInt_t w, UInt_t h) :
00037 TGMainFrame(p, w, h)
00038 {
00039
00040
00041 TGHorizontalFrame *fHf = new TGHorizontalFrame(this, 50, 50);
00042
00043 TGVerticalFrame *fV1 = new TGVerticalFrame(fHf, 10, 10, kFixedWidth);
00044 TGVerticalFrame *fV2 = new TGVerticalFrame(fHf, 10, 10);
00045 TGCompositeFrame *fFleft = new TGCompositeFrame(fV1, 10, 10, kSunkenFrame);
00046 TGCompositeFrame *fFright = new TGCompositeFrame(fV2, 10, 10, kSunkenFrame);
00047
00048 TGLabel *fLleft = new TGLabel(fFleft, "Left Frame");
00049 TGLabel *fLright = new TGLabel(fFright, "Right Frame");
00050
00051 fFleft->AddFrame(fLleft, new TGLayoutHints(kLHintsLeft | kLHintsCenterY,
00052 3, 0, 0, 0));
00053 fFright->AddFrame(fLright, new TGLayoutHints(kLHintsLeft | kLHintsCenterY,
00054 3, 0, 0, 0));
00055
00056 fV1->AddFrame(fFleft, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY,
00057 0, 0, 5, 10));
00058 fV2->AddFrame(fFright, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY,
00059 0, 0, 5, 10));
00060
00061 fV1->Resize(fFleft->GetDefaultWidth()+20, fV1->GetDefaultHeight());
00062 fV2->Resize(fFright->GetDefaultWidth(), fV1->GetDefaultHeight());
00063 fHf->AddFrame(fV1, new TGLayoutHints(kLHintsLeft | kLHintsExpandY));
00064
00065 TGVSplitter *splitter = new TGVSplitter(fHf,2,2);
00066 splitter->SetFrame(fV1, kTRUE);
00067 fHf->AddFrame(splitter, new TGLayoutHints(kLHintsLeft | kLHintsExpandY));
00068
00069 fHf->AddFrame(fV2, new TGLayoutHints(kLHintsRight | kLHintsExpandX |
00070 kLHintsExpandY));
00071 AddFrame(fHf, new TGLayoutHints(kLHintsRight | kLHintsExpandX |
00072 kLHintsExpandY));
00073
00074
00075 TGVerticalFrame *vframe = new TGVerticalFrame(this, 10, 10);
00076 TGCompositeFrame *cframe2 = new TGCompositeFrame(vframe, 170, 20,
00077 kHorizontalFrame | kFixedWidth);
00078 TGTextButton *save = new TGTextButton(cframe2, "&Save");
00079 cframe2->AddFrame(save, new TGLayoutHints(kLHintsTop | kLHintsExpandX,
00080 3, 2, 2, 2));
00081 save->Connect("Clicked()", "MyMainFrame", this, "DoSave()");
00082 save->SetToolTipText("Click on the button to save the application as C++ macro");
00083
00084 TGTextButton *exit = new TGTextButton(cframe2, "&Exit ","gApplication->Terminate(0)");
00085 cframe2->AddFrame(exit, new TGLayoutHints(kLHintsTop | kLHintsExpandX,
00086 2, 0, 2, 2));
00087 vframe->AddFrame(cframe2, new TGLayoutHints(kLHintsExpandX, 2, 2, 5, 1));
00088 AddFrame(vframe, new TGLayoutHints(kLHintsExpandX, 2, 2, 5, 1));
00089
00090
00091 SetCleanup(kDeepCleanup);
00092
00093
00094 SetWindowName("Vertical Splitter");
00095 SetWMSizeHints(350, 200, 600, 400, 0, 0);
00096 MapSubwindows();
00097 Resize(GetDefaultSize());
00098 MapWindow();
00099 }
00100
00101
00102
00103 MyMainFrame::~MyMainFrame()
00104 {
00105
00106 Cleanup();
00107 }
00108
00109
00110 void MyMainFrame::CloseWindow()
00111 {
00112
00113
00114 delete this;
00115 }
00116
00117 void splitterVertical()
00118 {
00119
00120 new MyMainFrame(gClient->GetRoot(), 350, 200);
00121 }