00001
00002
00003
00004
00005
00006
00007
00008
00009
00010 #include <TSystem.h>
00011 #include <TRootHelpDialog.h>
00012
00013 #include "RSMsgBox.h"
00014 #include "RootShower.h"
00015 #include "RSHelpText.h"
00016
00017
00018 RootShowerMsgBox::RootShowerMsgBox(const TGWindow *p, const TGWindow *main,
00019 UInt_t w, UInt_t h, UInt_t options) :
00020 TGTransientFrame(p, main, w, h, options)
00021 {
00022 TGPicture *fIconPicture;
00023 TGIcon *fIcon;
00024 UInt_t wh1 = (UInt_t)(0.6 * h);
00025 UInt_t wh2 = h - wh1;
00026
00027 fVFrame = new TGVerticalFrame(this, w, wh1, 0);
00028
00029 TString theLogoFilename = StrDup(gProgPath);
00030 theLogoFilename.Append("/icons/mclogo01.xpm");
00031 fIconPicture = (TGPicture *)gClient->GetPicture(theLogoFilename);
00032 fIcon = new TGIcon(this, fIconPicture,
00033 fIconPicture->GetWidth(),
00034 fIconPicture->GetHeight());
00035 fLogoLayout = new TGLayoutHints(kLHintsCenterX, 0, 0, 0, 0);
00036 AddFrame(fIcon, fLogoLayout);
00037
00038 fLabel1 = new TGLabel(fVFrame, "Appears that You have changed some parameters");
00039 fLabel2 = new TGLabel(fVFrame, "Would You wish to SAVE changes ?");
00040
00041 fBly = new TGLayoutHints(kLHintsTop | kLHintsLeft | kLHintsExpandX, 0, 0, 5, 5);
00042 fBfly = new TGLayoutHints(kLHintsTop | kLHintsRight| kLHintsExpandX, 0, 0, 5, 5);
00043
00044 fVFrame->AddFrame(fLabel1,fBly);
00045 fVFrame->AddFrame(fLabel2,fBly);
00046
00047
00048
00049
00050
00051 fHFrame = new TGHorizontalFrame(this, w, wh2, 0);
00052
00053 fOkButton = new TGTextButton(fHFrame, "&Yes", 1);
00054 fOkButton->Associate(this);
00055
00056 fHelpButton = new TGTextButton(fHFrame, "&Help", 2);
00057 fHelpButton->Associate(this);
00058
00059 fCancelButton = new TGTextButton(fHFrame, "&No", 3);
00060 fCancelButton->Associate(this);
00061
00062 fL1 = new TGLayoutHints(kLHintsTop | kLHintsLeft | kLHintsExpandX,
00063 2, 2, 2, 2);
00064 fL2 = new TGLayoutHints(kLHintsBottom | kLHintsLeft | kLHintsExpandX,
00065 10, 10, 5, 10);
00066
00067 fHFrame->AddFrame(fOkButton, fL1);
00068 fHFrame->AddFrame(fHelpButton, fL1);
00069 fHFrame->AddFrame(fCancelButton, fL1);
00070
00071 fHFrame->Resize(w, fOkButton->GetDefaultHeight());
00072
00073 AddFrame(fVFrame, fBfly);
00074 AddFrame(fHFrame, fL2);
00075
00076 SetWindowName("Root's Monte Carlo Message Box");
00077 TGDimension size = GetDefaultSize();
00078 Resize(size);
00079
00080 SetWMSize(size.fWidth, size.fHeight);
00081 SetWMSizeHints(size.fWidth, size.fHeight, size.fWidth, size.fHeight, 0, 0);
00082 SetMWMHints(kMWMDecorAll | kMWMDecorResizeH | kMWMDecorMaximize |
00083 kMWMDecorMinimize | kMWMDecorMenu, kMWMFuncAll |
00084 kMWMFuncResize | kMWMFuncMaximize | kMWMFuncMinimize,
00085 kMWMInputModeless);
00086
00087
00088 Window_t wdummy;
00089 Int_t ax, ay;
00090 gVirtualX->TranslateCoordinates(main->GetId(), GetParent()->GetId(),
00091 (Int_t)(((TGFrame *) main)->GetWidth() - fWidth) >> 1,
00092 (Int_t)(((TGFrame *) main)->GetHeight() - fHeight) >> 1,
00093 ax, ay, wdummy);
00094 Move(ax, ay);
00095
00096 MapSubwindows();
00097 MapWindow();
00098
00099 fClient->WaitFor(this);
00100 }
00101
00102
00103 RootShowerMsgBox::~RootShowerMsgBox()
00104 {
00105 delete fLogoLayout;
00106 delete fCancelButton;
00107 delete fHelpButton;
00108 delete fOkButton;
00109 delete fVFrame;
00110 delete fHFrame;
00111 delete fLabel1;
00112 delete fLabel2;
00113 delete fBly;
00114 }
00115
00116
00117 void RootShowerMsgBox::CloseWindow()
00118 {
00119
00120
00121 DeleteWindow();
00122 }
00123
00124
00125 Bool_t RootShowerMsgBox::ProcessMessage(Long_t msg, Long_t parm1, Long_t )
00126 {
00127
00128 TRootHelpDialog* hd;
00129
00130 switch (GET_MSG(msg)) {
00131
00132 case kC_COMMAND:
00133 switch (GET_SUBMSG(msg)) {
00134 case kCM_BUTTON:
00135 switch(parm1) {
00136 case 1:
00137 gRootShower->SetOk();
00138 CloseWindow();
00139 break;
00140 case 2:
00141 hd = new TRootHelpDialog(this, "Help on Message Box", 590, 200);
00142 hd->SetText(gRSHelpMsgBox);
00143 hd->Popup();
00144 fClient->WaitFor(hd);
00145 break;
00146 case 3:
00147 gRootShower->SetOk(false);
00148 CloseWindow();
00149 break;
00150 default:
00151 break;
00152 }
00153 break;
00154 default:
00155 break;
00156 }
00157 break;
00158 }
00159 return kTRUE;
00160 }
00161