#include "TGFrame.h"
#include "TGMdiFrame.h"
#include "TGMdiMainFrame.h"
#include "TGMdiDecorFrame.h"
#include "Riostream.h"
ClassImp(TGMdiFrame)
TGMdiFrame::TGMdiFrame(TGMdiMainFrame *main, Int_t w, Int_t h, UInt_t options,
Pixel_t back) :
TGCompositeFrame(main->GetContainer(), w, h,
options | kOwnBackground | kMdiFrame, back)
{
fMain = main;
fMain->AddMdiFrame(this);
fMdiHints = kMdiDefaultHints;
}
TGMdiFrame::~TGMdiFrame()
{
Cleanup();
fMain->RemoveMdiFrame(this);
}
Bool_t TGMdiFrame::CloseWindow()
{
DeleteWindow();
return kTRUE;
}
void TGMdiFrame::DontCallClose()
{
SetBit(kDontCallClose);
}
void TGMdiFrame::SetMdiHints(ULong_t mdihints)
{
fMdiHints = mdihints;
((TGMdiDecorFrame *)fParent)->SetMdiButtons(mdihints);
}
void TGMdiFrame::SetWindowName(const char *name)
{
((TGMdiDecorFrame *)fParent)->SetWindowName(name);
fMain->UpdateWinListMenu();
}
void TGMdiFrame::SetWindowIcon(const TGPicture *pic)
{
((TGMdiDecorFrame *)fParent)->SetWindowIcon(pic);
fMain->UpdateWinListMenu();
}
const char *TGMdiFrame::GetWindowName()
{
return ((TGMdiDecorFrame *)fParent)->GetWindowName();
}
const TGPicture *TGMdiFrame::GetWindowIcon()
{
return ((TGMdiDecorFrame *)fParent)->GetWindowIcon();
}
void TGMdiFrame::Move(Int_t x, Int_t y)
{
((TGMdiDecorFrame *)fParent)->Move(x, y);
fX = x; fY = y;
}
TString TGMdiFrame::GetMdiHintsString() const
{
TString hints;
if (fMdiHints == kMdiDefaultHints)
hints = "kMdiDefaultHints";
else {
if (fMdiHints & kMdiClose) {
if (hints.Length() == 0) hints = "kMdiClose";
else hints += " | kMdiClose";
}
if (fMdiHints & kMdiRestore) {
if (hints.Length() == 0) hints = "kMdiRestore";
else hints += " | kMdiRestore";
}
if (fMdiHints & kMdiMove) {
if (hints.Length() == 0) hints = "kMdiMove";
else hints += " | kMdiMove";
}
if (fMdiHints & kMdiSize) {
if (hints.Length() == 0) hints = "kMdiSize";
else hints += " | kMdiSize";
}
if (fMdiHints & kMdiMinimize) {
if (hints.Length() == 0) hints = "kMdiMinimize";
else hints += " | kMdiMinimize";
}
if (fMdiHints & kMdiMaximize) {
if (hints.Length() == 0) hints = "kMdiMaximize";
else hints += " | kMdiMaximize";
}
if (fMdiHints & kMdiHelp) {
if (hints.Length() == 0) hints = "kMdiHelp";
else hints += " | kMdiHelp";
}
if (fMdiHints & kMdiMenu) {
if (hints.Length() == 0) hints = "kMdiMenu";
else hints += " | kMdiMenu";
}
}
return hints;
}
void TGMdiFrame::SavePrimitive(ostream &out, Option_t *option )
{
char quote = '"';
if (fBackground != GetDefaultFrameBackground()) SaveUserColor(out, option);
TGMdiTitleBar *tb = fMain->GetWindowList()->GetDecorFrame()->GetTitleBar();
out << endl <<" // MDI frame "<< quote << GetWindowName() << quote << endl;
out << " TGMdiFrame *";
out << GetName() << " = new TGMdiFrame(" << fMain->GetName()
<< "," << GetWidth() + GetBorderWidth()*2
<< "," << GetHeight() + tb->GetHeight() + GetBorderWidth()*2;
if (fBackground == GetDefaultFrameBackground()) {
if (!GetOptions()) {
out << ");" << endl;
} else {
out << "," << GetOptionString() <<");" << endl;
}
} else {
out << "," << GetOptionString() << ",ucolor);" << endl;
}
SavePrimitiveSubframes(out, option);
out << " " << GetName() << "->SetWindowName(" << quote << GetWindowName()
<< quote << ");" << endl;
out << " " << GetName() << "->SetMdiHints(" << GetMdiHintsString()
<< ");" << endl;
if ((GetX() != 5) && (GetY() != 23))
out << " " << GetName() << "->Move(" << GetX() << "," << GetY()
<< ");" << endl;
out << " " << GetName() << "->MapSubwindows();" << endl;
out << " " << GetName() << "->Layout();" << endl;
}