00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041 #include "TGMdi.h"
00042 #include "TGMdiMenu.h"
00043 #include "TList.h"
00044 #include "Riostream.h"
00045
00046
00047 ClassImp(TGMdiMenuBar)
00048
00049
00050 TGMdiMenuBar::TGMdiMenuBar(const TGWindow *p, int w, int h) :
00051 TGCompositeFrame(p, w, h, kHorizontalFrame)
00052 {
00053
00054
00055 fLHint = new TGLayoutHints(kLHintsNormal);
00056 fLeftHint = new TGLayoutHints(kLHintsLeft | kLHintsCenterY, 1, 1, 1, 1);
00057 fBarHint = new TGLayoutHints(kLHintsExpandX | kLHintsCenterY, 1, 1, 1, 1);
00058 fRightHint = new TGLayoutHints(kLHintsRight | kLHintsCenterY, 1, 2, 1, 1);
00059
00060 fLeft = new TGCompositeFrame(this, 10, 10, kHorizontalFrame);
00061 fBar = new TGMenuBar(this, 1, 20, kHorizontalFrame);
00062 fRight = new TGCompositeFrame(this, 10, 10, kHorizontalFrame);
00063
00064 AddFrame(fLeft, fLeftHint);
00065 AddFrame(fBar, fBarHint);
00066 AddFrame(fRight, fRightHint);
00067 }
00068
00069
00070 TGMdiMenuBar::~TGMdiMenuBar()
00071 {
00072
00073
00074 if (!MustCleanup()) {
00075 delete fLHint;
00076 delete fLeftHint;
00077 delete fRightHint;
00078 delete fBarHint;
00079 }
00080 }
00081
00082
00083 void TGMdiMenuBar::AddPopup(TGHotString *s, TGPopupMenu *menu, TGLayoutHints *l)
00084 {
00085
00086
00087 fBar->AddPopup(s, menu, l);
00088
00089 }
00090
00091
00092 void TGMdiMenuBar::AddFrames(TGMdiTitleIcon *icon, TGMdiButtons *buttons)
00093 {
00094
00095
00096
00097 TGFrameElement *el;
00098 TIter nextl(fLeft->GetList());
00099 while ((el = (TGFrameElement *) nextl())) {
00100 fLeft->HideFrame(el->fFrame);
00101 }
00102 TIter nextr(fRight->GetList());
00103 while ((el = (TGFrameElement *) nextr())) {
00104 fRight->HideFrame(el->fFrame);
00105 }
00106
00107 icon->ReparentWindow(fLeft);
00108 buttons->ReparentWindow(fRight);
00109 fLeft->AddFrame(icon, fLHint);
00110 fRight->AddFrame(buttons, fLHint);
00111 }
00112
00113
00114 void TGMdiMenuBar::RemoveFrames(TGMdiTitleIcon *icon, TGMdiButtons *buttons)
00115 {
00116
00117
00118
00119 fLeft->RemoveFrame(icon);
00120 fRight->RemoveFrame(buttons);
00121
00122 TGFrameElement *el;
00123 el = (TGFrameElement *)fLeft->GetList()->Last();
00124 if (el)
00125 fLeft->ShowFrame(el->fFrame);
00126 el = (TGFrameElement *)fRight->GetList()->Last();
00127 if (el)
00128 fRight->ShowFrame(el->fFrame);
00129 }
00130
00131
00132 void TGMdiMenuBar::ShowFrames(TGMdiTitleIcon *icon, TGMdiButtons *buttons)
00133 {
00134
00135
00136
00137 TGFrameElement *el;
00138 TIter nextl(fLeft->GetList());
00139 while ((el = (TGFrameElement *) nextl())) {
00140 fLeft->HideFrame(el->fFrame);
00141 }
00142 TIter nextr(fRight->GetList());
00143 while ((el = (TGFrameElement *) nextr())) {
00144 fRight->HideFrame(el->fFrame);
00145 }
00146
00147 fLeft->ShowFrame(icon);
00148 fRight->ShowFrame(buttons);
00149 }
00150
00151
00152 void TGMdiMenuBar::HideFrames(TGMdiTitleIcon *icon, TGMdiButtons *buttons)
00153 {
00154
00155
00156
00157 fLeft->HideFrame(icon);
00158 fRight->HideFrame(buttons);
00159
00160
00161 TGFrameElement *el;
00162 el = (TGFrameElement *)fLeft->GetList()->Last();
00163 if (el)
00164 fLeft->ShowFrame(el->fFrame);
00165 el = (TGFrameElement *)fRight->GetList()->Last();
00166 if (el)
00167 fRight->ShowFrame(el->fFrame);
00168 }
00169
00170
00171 void TGMdiMenuBar::SavePrimitive(ostream &out, Option_t *option )
00172 {
00173
00174
00175 out << endl;
00176 out << " // MDI menu bar" << endl;
00177
00178 out << " TGMdiMenuBar *";
00179 out << GetName() << " = new TGMdiMenuBar(" << fParent->GetName()
00180 << "," << GetWidth() << "," << GetHeight() << ");" << endl;
00181 if (option && strstr(option, "keep_names"))
00182 out << " " << GetName() << "->SetName(\"" << GetName() << "\");" << endl;
00183
00184 if (!fList) return;
00185
00186 out << " TGMenuBar *" << fBar->GetName() << " = " << GetName()
00187 << "->GetMenuBar();" << endl;
00188
00189 TGFrameElement *el;
00190 TIter next(fBar->GetList());
00191
00192 while ((el = (TGFrameElement *)next())) {
00193 el->fFrame->SavePrimitive(out, option);
00194 el->fLayout->SavePrimitive(out, option);
00195 out << ");" << endl;
00196 }
00197 }