36 ClassImp(TGUnknownWindowHandler);
38 Int_t TGWindow::fgCounter = 0;
45 TGWindow::TGWindow(
const TGWindow *p, Int_t x, Int_t y, UInt_t w, UInt_t h,
46 UInt_t border, Int_t depth, UInt_t clss,
void *visual,
47 SetWindowAttributes_t *attr, UInt_t wtype)
55 p = gClient->GetRoot();
60 if (fClient->IsEditable()) type = wtype & ~1;
63 if (fParent && fParent->IsMapSubwindows()) {
64 fId = gVirtualX->CreateWindow(fParent->fId, x, y,
65 TMath::Max(w, (UInt_t) 1),
66 TMath::Max(h, (UInt_t) 1), border,
67 depth, clss, visual, attr, type);
68 fClient->RegisterWindow(
this);
76 fEditDisabled = (fId != gVirtualX->GetDefaultRootWindow()) && fParent ?
77 (fParent->fEditDisabled == kEditDisable) : 0;
80 if (fClient && fClient->GetDefaultRoot())
87 TGWindow::TGWindow(TGClient *c, Window_t
id,
const TGWindow *parent)
92 fClient->RegisterWindow(
this);
94 fEditDisabled = (fId != gVirtualX->GetDefaultRootWindow()) && fParent ?
95 fParent->fEditDisabled : kFALSE;
106 TGWindow::~TGWindow()
109 if (fParent == fClient->GetDefaultRoot())
111 fClient->UnregisterWindow(
this);
118 void TGWindow::SetWindowName(
const char *name)
120 if (!name && gDebug > 0) {
122 TString wname = ClassName();
123 wname +=
"::" + fName;
124 gVirtualX->SetWindowName(fId, (
char *)wname.Data());
126 gVirtualX->SetWindowName(fId, (
char *)name);
133 const TGWindow *TGWindow::GetMainFrame()
const
135 return ((fParent == 0) || (fParent == fClient->GetDefaultRoot())) ?
this : fParent->GetMainFrame();
142 void TGWindow::ReparentWindow(
const TGWindow *p, Int_t x, Int_t y)
144 if (p == fParent)
return;
147 gVirtualX->ReparentWindow(fId, p->GetId(), x, y);
148 gVirtualX->Update(1);
156 void TGWindow::Move(Int_t x, Int_t y)
158 gVirtualX->MoveWindow(fId, x, y);
164 void TGWindow::Resize(UInt_t w, UInt_t h)
166 gVirtualX->ResizeWindow(fId, TMath::Max(w, (UInt_t)1), TMath::Max(h, (UInt_t)1));
172 void TGWindow::MoveResize(Int_t x, Int_t y, UInt_t w, UInt_t h)
174 gVirtualX->MoveResizeWindow(fId, x, y, TMath::Max(w, (UInt_t)1), TMath::Max(h, (UInt_t)1));
180 Bool_t TGWindow::IsMapped()
182 WindowAttributes_t attr;
184 gVirtualX->GetWindowAttributes(fId, attr);
185 return (attr.fMapState != kIsUnmapped);
192 void TGWindow::Print(Option_t *option)
const
194 TString opt = option;
196 if (opt.Contains(
"tree")) {
198 const TGWindow *parent = fParent;
199 std::cout << ClassName() <<
":\t" << fId << std::endl;
201 while (parent && (parent != fClient->GetDefaultRoot())) {
202 std::cout <<
"\t" << parent->ClassName() <<
":\t" << parent->GetId() << std::endl;
203 parent = parent->GetParent();
206 std::cout << ClassName() <<
":\t" << fId << std::endl;
213 Int_t TGWindow::GetCounter()
221 const char *TGWindow::GetName()
const
223 TGWindow *w = (TGWindow*)
this;
225 if (fName.BeginsWith(
"frame")) {
226 TString cname = ClassName();
227 if (cname.BeginsWith(
"TGed"))
228 cname.Replace(0, 1,
'f');
229 else if (cname.BeginsWith(
"TG"))
230 cname.Replace(0,2,
'f');
232 cname.Replace(0, 1,
'f');
233 w->fName.Remove(0,5);
234 w->fName = cname + w->fName;
237 if (w->fName.Contains(
" "))
238 w->fName.ReplaceAll(
" ",
"");
239 if (w->fName.Contains(
":"))
240 w->fName.ReplaceAll(
":",
"");