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 "TGFrame.h"
00042 #include "TGMdiFrame.h"
00043 #include "TGMdiMainFrame.h"
00044 #include "TGMdiDecorFrame.h"
00045 #include "Riostream.h"
00046
00047 ClassImp(TGMdiFrame)
00048
00049
00050 TGMdiFrame::TGMdiFrame(TGMdiMainFrame *main, Int_t w, Int_t h, UInt_t options,
00051 Pixel_t back) :
00052 TGCompositeFrame(main->GetContainer(), w, h,
00053 options | kOwnBackground | kMdiFrame, back)
00054 {
00055
00056
00057 fMain = main;
00058 fMain->AddMdiFrame(this);
00059 fMdiHints = kMdiDefaultHints;
00060 }
00061
00062
00063 TGMdiFrame::~TGMdiFrame()
00064 {
00065
00066
00067 Cleanup();
00068 fMain->RemoveMdiFrame(this);
00069 }
00070
00071
00072 Bool_t TGMdiFrame::CloseWindow()
00073 {
00074
00075
00076 DeleteWindow();
00077 return kTRUE;
00078 }
00079
00080
00081 void TGMdiFrame::DontCallClose()
00082 {
00083
00084
00085
00086
00087 SetBit(kDontCallClose);
00088 }
00089
00090
00091 void TGMdiFrame::SetMdiHints(ULong_t mdihints)
00092 {
00093
00094
00095 fMdiHints = mdihints;
00096 ((TGMdiDecorFrame *)fParent)->SetMdiButtons(mdihints);
00097 }
00098
00099
00100 void TGMdiFrame::SetWindowName(const char *name)
00101 {
00102
00103
00104 ((TGMdiDecorFrame *)fParent)->SetWindowName(name);
00105 fMain->UpdateWinListMenu();
00106 }
00107
00108
00109 void TGMdiFrame::SetWindowIcon(const TGPicture *pic)
00110 {
00111
00112
00113 ((TGMdiDecorFrame *)fParent)->SetWindowIcon(pic);
00114 fMain->UpdateWinListMenu();
00115 }
00116
00117
00118 const char *TGMdiFrame::GetWindowName()
00119 {
00120
00121
00122 return ((TGMdiDecorFrame *)fParent)->GetWindowName();
00123 }
00124
00125
00126 const TGPicture *TGMdiFrame::GetWindowIcon()
00127 {
00128
00129
00130 return ((TGMdiDecorFrame *)fParent)->GetWindowIcon();
00131 }
00132
00133
00134 void TGMdiFrame::Move(Int_t x, Int_t y)
00135 {
00136
00137
00138 ((TGMdiDecorFrame *)fParent)->Move(x, y);
00139 fX = x; fY = y;
00140 }
00141
00142
00143 TString TGMdiFrame::GetMdiHintsString() const
00144 {
00145
00146
00147 TString hints;
00148 if (fMdiHints == kMdiDefaultHints)
00149 hints = "kMdiDefaultHints";
00150 else {
00151 if (fMdiHints & kMdiClose) {
00152 if (hints.Length() == 0) hints = "kMdiClose";
00153 else hints += " | kMdiClose";
00154 }
00155 if (fMdiHints & kMdiRestore) {
00156 if (hints.Length() == 0) hints = "kMdiRestore";
00157 else hints += " | kMdiRestore";
00158 }
00159 if (fMdiHints & kMdiMove) {
00160 if (hints.Length() == 0) hints = "kMdiMove";
00161 else hints += " | kMdiMove";
00162 }
00163 if (fMdiHints & kMdiSize) {
00164 if (hints.Length() == 0) hints = "kMdiSize";
00165 else hints += " | kMdiSize";
00166 }
00167 if (fMdiHints & kMdiMinimize) {
00168 if (hints.Length() == 0) hints = "kMdiMinimize";
00169 else hints += " | kMdiMinimize";
00170 }
00171 if (fMdiHints & kMdiMaximize) {
00172 if (hints.Length() == 0) hints = "kMdiMaximize";
00173 else hints += " | kMdiMaximize";
00174 }
00175 if (fMdiHints & kMdiHelp) {
00176 if (hints.Length() == 0) hints = "kMdiHelp";
00177 else hints += " | kMdiHelp";
00178 }
00179 if (fMdiHints & kMdiMenu) {
00180 if (hints.Length() == 0) hints = "kMdiMenu";
00181 else hints += " | kMdiMenu";
00182 }
00183 }
00184 return hints;
00185 }
00186
00187
00188 void TGMdiFrame::SavePrimitive(ostream &out, Option_t *option )
00189 {
00190
00191
00192 char quote = '"';
00193
00194 if (fBackground != GetDefaultFrameBackground()) SaveUserColor(out, option);
00195
00196 TGMdiTitleBar *tb = fMain->GetWindowList()->GetDecorFrame()->GetTitleBar();
00197
00198 out << endl <<" // MDI frame "<< quote << GetWindowName() << quote << endl;
00199 out << " TGMdiFrame *";
00200 out << GetName() << " = new TGMdiFrame(" << fMain->GetName()
00201 << "," << GetWidth() + GetBorderWidth()*2
00202 << "," << GetHeight() + tb->GetHeight() + GetBorderWidth()*2;
00203
00204 if (fBackground == GetDefaultFrameBackground()) {
00205 if (!GetOptions()) {
00206 out << ");" << endl;
00207 } else {
00208 out << "," << GetOptionString() <<");" << endl;
00209 }
00210 } else {
00211 out << "," << GetOptionString() << ",ucolor);" << endl;
00212 }
00213 if (option && strstr(option, "keep_names"))
00214 out << " " << GetName() << "->SetName(\"" << GetName() << "\");" << endl;
00215
00216 SavePrimitiveSubframes(out, option);
00217
00218 out << " " << GetName() << "->SetWindowName(" << quote << GetWindowName()
00219 << quote << ");" << endl;
00220 out << " " << GetName() << "->SetMdiHints(" << GetMdiHintsString()
00221 << ");" << endl;
00222 if ((GetX() != 5) && (GetY() != 23))
00223 out << " " << GetName() << "->Move(" << GetX() << "," << GetY()
00224 << ");" << endl;
00225
00226 out << " " << GetName() << "->MapSubwindows();" << endl;
00227 out << " " << GetName() << "->Layout();" << endl;
00228 }