94 Bool_t TGFrame::fgInit = kFALSE;
95 Pixel_t TGFrame::fgDefaultFrameBackground = 0;
96 Pixel_t TGFrame::fgDefaultSelectedBackground = 0;
97 Pixel_t TGFrame::fgWhitePixel = 0;
98 Pixel_t TGFrame::fgBlackPixel = 0;
99 const TGGC *TGFrame::fgBlackGC = 0;
100 const TGGC *TGFrame::fgWhiteGC = 0;
101 const TGGC *TGFrame::fgHilightGC = 0;
102 const TGGC *TGFrame::fgShadowGC = 0;
103 const TGGC *TGFrame::fgBckgndGC = 0;
104 Time_t TGFrame::fgLastClick = 0;
105 UInt_t TGFrame::fgLastButton = 0;
106 Int_t TGFrame::fgDbx = 0;
107 Int_t TGFrame::fgDby = 0;
108 Window_t TGFrame::fgDbw = 0;
109 UInt_t TGFrame::fgUserColor = 0;
111 const TGFont *TGGroupFrame::fgDefaultFont = 0;
112 const TGGC *TGGroupFrame::fgDefaultGC = 0;
114 TGLayoutHints *TGCompositeFrame::fgDefaultHints = 0;
116 static const char *gSaveMacroTypes[] = {
117 "ROOT macros",
"*.C",
127 TList *gListOfHiddenFrames =
new TList();
130 ClassImp(TGCompositeFrame);
131 ClassImp(TGVerticalFrame);
132 ClassImp(TGHorizontalFrame);
133 ClassImp(TGMainFrame);
134 ClassImp(TGTransientFrame);
135 ClassImp(TGGroupFrame);
136 ClassImp(TGHeaderFrame);
142 TGFrame::TGFrame(
const TGWindow *p, UInt_t w, UInt_t h,
143 UInt_t options, Pixel_t back)
144 : TGWindow(p, 0, 0, w, h, 0, 0, 0, 0, 0, options)
146 if (!fgInit && gClient) {
147 TGFrame::GetDefaultFrameBackground();
148 TGFrame::GetDefaultSelectedBackground();
149 TGFrame::GetWhitePixel();
150 TGFrame::GetBlackPixel();
151 TGFrame::GetBlackGC();
152 TGFrame::GetWhiteGC();
153 TGFrame::GetHilightGC();
154 TGFrame::GetShadowGC();
155 TGFrame::GetBckgndGC();
159 SetWindowAttributes_t wattr;
164 fWidth = w; fHeight = h; fX = fY = fBorderWidth = 0;
167 fMaxWidth = kMaxUInt;
168 fMaxHeight = kMaxUInt;
171 if (fOptions & (kSunkenFrame | kRaisedFrame))
172 fBorderWidth = (gClient->GetStyle() > 1) ? 1 : (fOptions & kDoubleBorder) ? 2 : 1;
174 wattr.fMask = kWABackPixel | kWAEventMask;
175 wattr.fBackgroundPixel = back;
176 wattr.fEventMask = kExposureMask;
177 if (fOptions & kMainFrame) {
178 wattr.fEventMask |= kStructureNotifyMask;
179 gVirtualX->ChangeWindowAttributes(fId, &wattr);
183 gVirtualX->ChangeWindowAttributes(fId, &wattr);
187 fEventMask = (UInt_t) wattr.fEventMask;
189 if ((fOptions & kDoubleBorder) && (gClient->GetStyle() > 1))
190 ChangeOptions(fOptions ^ kDoubleBorder);
201 TGFrame::TGFrame(TGClient *c, Window_t
id,
const TGWindow *parent)
202 : TGWindow(c, id, parent)
204 if (!fgInit && gClient) {
205 TGFrame::GetDefaultFrameBackground();
206 TGFrame::GetDefaultSelectedBackground();
207 TGFrame::GetWhitePixel();
208 TGFrame::GetBlackPixel();
209 TGFrame::GetBlackGC();
210 TGFrame::GetWhiteGC();
211 TGFrame::GetHilightGC();
212 TGFrame::GetShadowGC();
213 TGFrame::GetBckgndGC();
217 WindowAttributes_t attributes;
221 attributes.fWidth = 100;
222 attributes.fHeight = 100;
223 attributes.fBorderWidth = 4;
224 attributes.fYourEventMask = 0;
225 gVirtualX->GetWindowAttributes(
id, attributes);
230 fWidth = attributes.fWidth;
231 fHeight = attributes.fHeight;
232 fBorderWidth = attributes.fBorderWidth;
233 fEventMask = (UInt_t) attributes.fYourEventMask;
238 fMaxWidth = kMaxUInt;
239 fMaxHeight = kMaxUInt;
258 void TGFrame::DeleteWindow()
261 if (gDNDManager->GetMainFrame() ==
this)
262 gDNDManager->SetMainFrame(0);
264 if (!TestBit(kDeleteWindowCalled)) {
267 TTimer::SingleShot(150, IsA()->GetName(),
this,
"ReallyDelete()");
269 SetBit(kDeleteWindowCalled);
275 void TGFrame::ChangeBackground(Pixel_t back)
278 gVirtualX->SetWindowBackground(fId, back);
279 fClient->NeedRedraw(
this);
285 Pixel_t TGFrame::GetForeground()
const
294 void TGFrame::SetBackgroundColor(Pixel_t back)
297 TGWindow::SetBackgroundColor(back);
303 void TGFrame::ChangeOptions(UInt_t options)
305 if ((options & (kDoubleBorder | kSunkenFrame | kRaisedFrame)) !=
306 (fOptions & (kDoubleBorder | kSunkenFrame | kRaisedFrame))) {
307 if (!InheritsFrom(TGGroupFrame::Class())) {
308 if (options & (kSunkenFrame | kRaisedFrame))
309 fBorderWidth = (gClient->GetStyle() > 1) ? 1 : (fOptions & kDoubleBorder) ? 2 : 1;
321 void TGFrame::AddInput(UInt_t emask)
324 gVirtualX->SelectInput(fId, fEventMask);
330 void TGFrame::RemoveInput(UInt_t emask)
332 fEventMask &= ~emask;
333 gVirtualX->SelectInput(fId, fEventMask);
339 void TGFrame::Draw3dRectangle(UInt_t type, Int_t x, Int_t y,
344 gVirtualX->DrawLine(fId, GetShadowGC()(), x, y, x+w-2, y);
345 gVirtualX->DrawLine(fId, GetShadowGC()(), x, y, x, y+h-2);
346 gVirtualX->DrawLine(fId, GetHilightGC()(), x, y+h-1, x+w-1, y+h-1);
347 gVirtualX->DrawLine(fId, GetHilightGC()(), x+w-1, y+h-1, x+w-1, y);
350 case kSunkenFrame | kDoubleBorder:
351 if (gClient->GetStyle() < 2) {
352 gVirtualX->DrawLine(fId, GetShadowGC()(), x, y, x+w-2, y);
353 gVirtualX->DrawLine(fId, GetShadowGC()(), x, y, x, y+h-2);
354 gVirtualX->DrawLine(fId, GetBlackGC()(), x+1, y+1, x+w-3, y+1);
355 gVirtualX->DrawLine(fId, GetBlackGC()(), x+1, y+1, x+1, y+h-3);
356 gVirtualX->DrawLine(fId, GetHilightGC()(), x, y+h-1, x+w-1, y+h-1);
357 gVirtualX->DrawLine(fId, GetHilightGC()(), x+w-1, y+h-1, x+w-1, y);
358 gVirtualX->DrawLine(fId, GetBckgndGC()(), x+1, y+h-2, x+w-2, y+h-2);
359 gVirtualX->DrawLine(fId, GetBckgndGC()(), x+w-2, y+1, x+w-2, y+h-2);
362 gVirtualX->DrawLine(fId, GetShadowGC()(), x, y, x+w-2, y);
363 gVirtualX->DrawLine(fId, GetShadowGC()(), x, y, x, y+h-2);
364 gVirtualX->DrawLine(fId, GetHilightGC()(), x, y+h-1, x+w-1, y+h-1);
365 gVirtualX->DrawLine(fId, GetHilightGC()(), x+w-1, y+h-1, x+w-1, y);
370 gVirtualX->DrawLine(fId, GetHilightGC()(), x, y, x+w-2, y);
371 gVirtualX->DrawLine(fId, GetHilightGC()(), x, y, x, y+h-2);
372 gVirtualX->DrawLine(fId, GetShadowGC()(), x, y+h-1, x+w-1, y+h-1);
373 gVirtualX->DrawLine(fId, GetShadowGC()(), x+w-1, y+h-1, x+w-1, y);
376 case kRaisedFrame | kDoubleBorder:
377 if (gClient->GetStyle() < 2) {
378 gVirtualX->DrawLine(fId, GetHilightGC()(), x, y, x+w-2, y);
379 gVirtualX->DrawLine(fId, GetHilightGC()(), x, y, x, y+h-2);
380 gVirtualX->DrawLine(fId, GetBckgndGC()(), x+1, y+1, x+w-3, y+1);
381 gVirtualX->DrawLine(fId, GetBckgndGC()(), x+1, y+1, x+1, y+h-3);
382 gVirtualX->DrawLine(fId, GetShadowGC()(), x+1, y+h-2, x+w-2, y+h-2);
383 gVirtualX->DrawLine(fId, GetShadowGC()(), x+w-2, y+h-2, x+w-2, y+1);
384 gVirtualX->DrawLine(fId, GetBlackGC()(), x, y+h-1, x+w-1, y+h-1);
385 gVirtualX->DrawLine(fId, GetBlackGC()(), x+w-1, y+h-1, x+w-1, y);
388 gVirtualX->DrawLine(fId, GetHilightGC()(), x, y, x+w-2, y);
389 gVirtualX->DrawLine(fId, GetHilightGC()(), x, y, x, y+h-2);
390 gVirtualX->DrawLine(fId, GetShadowGC()(), x, y+h-1, x+w-1, y+h-1);
391 gVirtualX->DrawLine(fId, GetShadowGC()(), x+w-1, y+h-1, x+w-1, y);
403 void TGFrame::DrawBorder()
405 Draw3dRectangle(fOptions & (kSunkenFrame | kRaisedFrame | kDoubleBorder),
406 0, 0, fWidth, fHeight);
412 void TGFrame::DoRedraw()
414 gVirtualX->ClearArea(fId, fBorderWidth, fBorderWidth,
415 fWidth - (fBorderWidth << 1), fHeight - (fBorderWidth << 1));
425 Bool_t TGFrame::HandleConfigureNotify(Event_t *event)
427 if ((event->fWidth != fWidth) || (event->fHeight != fHeight)) {
428 fWidth =
event->fWidth;
429 fHeight =
event->fHeight;
439 Bool_t TGFrame::HandleEvent(Event_t *event)
441 if (gDragManager && !fClient->IsEditDisabled() &&
442 gDragManager->HandleEvent(event))
return kTRUE;
444 TObjectSpy deleteCheck(
this);
446 switch (event->fType) {
452 case kConfigureNotify:
453 while (gVirtualX->CheckEvent(fId, kConfigureNotify, *event))
456 if ((event->fWidth < 32768) && (
event->fHeight < 32768)){
457 ProcessedConfigure(event);
458 HandleConfigureNotify(event);
469 HandleFocusChange(event);
474 Int_t dbl_clk = kFALSE;
476 if ((event->fTime - fgLastClick < 350) &&
477 (event->fCode == fgLastButton) &&
478 (TMath::Abs(event->fXRoot - fgDbx) < 6) &&
479 (TMath::Abs(event->fYRoot - fgDby) < 6) &&
480 (event->fWindow == fgDbw))
483 fgLastClick =
event->fTime;
484 fgLastButton =
event->fCode;
485 fgDbx =
event->fXRoot;
486 fgDby =
event->fYRoot;
487 fgDbw =
event->fWindow;
490 if ((event->fState & kKeyControlMask) &&
491 !GetEditDisabled() && gGuiBuilder) {
492 StartGuiBuilding(!IsEditable());
496 if (!HandleDoubleClick(event)) {
505 case kButtonDoubleClick:
507 fgLastClick =
event->fTime;
508 fgLastButton =
event->fCode;
509 fgDbx =
event->fXRoot;
510 fgDby =
event->fYRoot;
511 fgDbw =
event->fWindow;
513 HandleDoubleClick(event);
523 HandleCrossing(event);
527 while (gVirtualX->CheckEvent(fId, kMotionNotify, *event))
533 HandleClientMessage(event);
536 case kSelectionNotify:
537 HandleSelection(event);
540 case kSelectionRequest:
541 HandleSelectionRequest(event);
544 case kSelectionClear:
545 HandleSelectionClear(event);
548 case kColormapNotify:
549 HandleColormapChange(event);
557 if (deleteCheck.GetObject())
558 ProcessedEvent(event);
566 TGDimension TGFrame::GetDefaultSize()
const
568 return TGDimension(fWidth, fHeight);
575 void TGFrame::Move(Int_t x, Int_t y)
577 if (x != fX || y != fY) {
578 TGWindow::Move(x, y);
587 void TGFrame::Resize(UInt_t w, UInt_t h)
589 if (w != fWidth || h != fHeight) {
590 TGDimension siz(0,0);
591 siz = GetDefaultSize();
592 fWidth = w ? w : siz.fWidth;
593 fHeight = h ? h : siz.fHeight;
594 TGWindow::Resize(fWidth, fHeight);
602 void TGFrame::Resize(TGDimension size)
604 Resize(size.fWidth, size.fHeight);
611 void TGFrame::MoveResize(Int_t x, Int_t y, UInt_t w, UInt_t h)
614 TGDimension siz(0,0);
615 siz = GetDefaultSize();
616 fWidth = w ? w : siz.fWidth;
617 fHeight = h ? h : siz.fHeight;
619 TGWindow::MoveResize(x, y, fWidth, fHeight);
627 void TGFrame::SendMessage(
const TGWindow *w, Long_t msg, Long_t parm1, Long_t parm2)
632 event.fType = kClientMessage;
634 event.fHandle = gROOT_MESSAGE;
636 event.fWindow = w->GetId();
637 event.fUser[0] = msg;
638 event.fUser[1] = parm1;
639 event.fUser[2] = parm2;
643 gVirtualX->SendEvent(w->GetId(), &event);
651 Bool_t TGFrame::HandleClientMessage(Event_t *event)
654 gDNDManager->HandleClientMessage(event);
656 if (event->fHandle == gROOT_MESSAGE) {
657 ProcessMessage(event->fUser[0], event->fUser[1], event->fUser[2]);
665 ULong_t TGFrame::GetDefaultFrameBackground()
667 static Bool_t init = kFALSE;
668 if (!init && gClient) {
669 fgDefaultFrameBackground = gClient->GetResourcePool()->GetFrameBgndColor();
672 return fgDefaultFrameBackground;
678 ULong_t TGFrame::GetDefaultSelectedBackground()
680 static Bool_t init = kFALSE;
681 if (!init && gClient) {
682 fgDefaultSelectedBackground = gClient->GetResourcePool()->GetSelectedBgndColor();
685 return fgDefaultSelectedBackground;
691 ULong_t TGFrame::GetWhitePixel()
693 static Bool_t init = kFALSE;
694 if (!init && gClient) {
695 fgWhitePixel = gClient->GetResourcePool()->GetWhiteColor();
704 ULong_t TGFrame::GetBlackPixel()
706 static Bool_t init = kFALSE;
707 if (!init && gClient) {
708 fgBlackPixel = gClient->GetResourcePool()->GetBlackColor();
717 const TGGC &TGFrame::GetBlackGC()
719 if (!fgBlackGC && gClient)
720 fgBlackGC = gClient->GetResourcePool()->GetBlackGC();
727 const TGGC &TGFrame::GetWhiteGC()
729 if (!fgWhiteGC && gClient)
730 fgWhiteGC = gClient->GetResourcePool()->GetWhiteGC();
737 const TGGC &TGFrame::GetHilightGC()
739 if (!fgHilightGC && gClient)
740 fgHilightGC = gClient->GetResourcePool()->GetFrameHiliteGC();
747 const TGGC &TGFrame::GetShadowGC()
749 if (!fgShadowGC && gClient)
750 fgShadowGC = gClient->GetResourcePool()->GetFrameShadowGC();
757 const TGGC &TGFrame::GetBckgndGC()
759 if (!fgBckgndGC && gClient)
760 fgBckgndGC = gClient->GetResourcePool()->GetFrameBckgndGC();
767 Time_t TGFrame::GetLastClick()
775 void TGFrame::Print(Option_t *option)
const
777 TString opt = option;
778 if (opt.Contains(
"tree")) {
779 TGWindow::Print(option);
783 std::cout << option << ClassName() <<
":\tid=" << fId <<
" parent=" << fParent->GetId();
784 std::cout <<
" x=" << fX <<
" y=" << fY;
785 std::cout <<
" w=" << fWidth <<
" h=" << fHeight << std::endl;
791 void TGFrame::SetDragType(Int_t)
798 void TGFrame::SetDropType(Int_t)
806 Int_t TGFrame::GetDragType()
const
808 return fClient->IsEditable();
815 Int_t TGFrame::GetDropType()
const
823 void TGFrame::StartGuiBuilding(Bool_t on)
825 if (GetEditDisabled())
return;
826 if (!gDragManager) gDragManager = TVirtualDragManager::Instance();
827 if (!gDragManager)
return;
829 TGCompositeFrame *comp = 0;
831 if (InheritsFrom(TGCompositeFrame::Class())) {
832 comp = (TGCompositeFrame *)
this;
833 }
else if (fParent->InheritsFrom(TGCompositeFrame::Class())) {
834 comp = (TGCompositeFrame*)fParent;
836 if (comp) comp->SetEditable(on);
843 TGCompositeFrame::TGCompositeFrame(
const TGWindow *p, UInt_t w, UInt_t h,
844 UInt_t options, Pixel_t back) : TGFrame(p, w, h, options, back)
848 fLayoutBroken = kFALSE;
849 fMustCleanup = kNoCleanup;
850 fMapSubwindows = fParent->IsMapSubwindows();
852 fgDefaultHints =
new TGLayoutHints;
854 if (fOptions & kHorizontalFrame)
855 SetLayoutManager(
new TGHorizontalLayout(
this));
857 SetLayoutManager(
new TGVerticalLayout(
this));
867 TGCompositeFrame::TGCompositeFrame(TGClient *c, Window_t
id,
const TGWindow *parent)
868 : TGFrame(c, id, parent)
872 fLayoutBroken = kFALSE;
873 fMustCleanup = kNoCleanup;
874 fMapSubwindows = fParent->IsMapSubwindows();
876 fgDefaultHints =
new TGLayoutHints;
878 SetLayoutManager(
new TGVerticalLayout(
this));
886 TGCompositeFrame::~TGCompositeFrame()
888 if (fMustCleanup != kNoCleanup) {
891 TGFrameElement *el = 0;
894 while ((el = (TGFrameElement *) next())) {
901 delete fLayoutManager;
909 Bool_t TGCompositeFrame::IsEditable()
const
911 return (fClient->GetRoot() == (TGWindow*)
this);
930 void TGCompositeFrame::SetEditable(Bool_t on)
932 if (on && ((fEditDisabled & kEditDisable) ||
933 (fEditDisabled & kEditDisableLayout)))
return;
936 fClient->SetRoot(
this);
940 if (gDragManager) gDragManager->SetEditable(on);
949 void TGCompositeFrame::Cleanup()
956 while ((el = (TGFrameElement *) next())) {
958 el->fFrame->SetFrameElement(0);
959 if (!gVirtualX->InheritsFrom(
"TGX11") && !gVirtualX->InheritsFrom(
"TGCocoa"))
960 el->fFrame->DestroyWindow();
964 if (el->fLayout && (el->fLayout != fgDefaultHints) &&
965 (el->fLayout->References() > 0)) {
966 el->fLayout->RemoveReference();
967 if (!el->fLayout->References()) {
968 el->fLayout->fFE = 0;
982 void TGCompositeFrame::SetLayoutManager(TGLayoutManager *l)
985 delete fLayoutManager;
988 Error(
"SetLayoutManager",
"no layout manager specified");
994 void TGCompositeFrame::SetLayoutBroken(Bool_t on)
1004 void TGCompositeFrame::SetEditDisabled(UInt_t on)
1007 UInt_t set = on & kEditDisable;
1010 if (set == kEditDisable) {
1014 while ((el = (TGFrameElement *) next())) {
1016 el->fFrame->SetEditDisabled(set);
1025 void TGCompositeFrame::ChangeOptions(UInt_t options)
1027 TGFrame::ChangeOptions(options);
1029 if (options & kHorizontalFrame)
1030 SetLayoutManager(
new TGHorizontalLayout(
this));
1031 else if (options & kVerticalFrame)
1032 SetLayoutManager(
new TGVerticalLayout(
this));
1054 void TGCompositeFrame::SetCleanup(Int_t mode)
1056 if (mode == fMustCleanup)
1059 fMustCleanup = mode;
1061 if (fMustCleanup == kDeepCleanup) {
1065 while ((el = (TGFrameElement *) next())) {
1066 if (el->fFrame->InheritsFrom(TGCompositeFrame::Class())) {
1067 el->fFrame->SetCleanup(kDeepCleanup);
1076 TGFrameElement* TGCompositeFrame::FindFrameElement(TGFrame *f)
const
1078 if (!fList)
return 0;
1083 while ((el = (TGFrameElement *) next()))
1084 if (el->fFrame == f)
1099 void TGCompositeFrame::AddFrame(TGFrame *f, TGLayoutHints *l)
1101 TGFrameElement *nw =
new TGFrameElement(f, l ? l : fgDefaultHints);
1106 if (fMustCleanup == kDeepCleanup)
1107 f->SetCleanup(kDeepCleanup);
1113 void TGCompositeFrame::RemoveAll()
1120 while ((el = (TGFrameElement *) next())) {
1122 if (el->fLayout) el->fLayout->RemoveReference();
1131 void TGCompositeFrame::RemoveFrame(TGFrame *f)
1133 TGFrameElement *el = FindFrameElement(f);
1137 if (el->fLayout) el->fLayout->RemoveReference();
1138 f->SetFrameElement(0);
1146 void TGCompositeFrame::MapSubwindows()
1148 if (!fMapSubwindows) {
1153 TGWindow::MapSubwindows();
1160 while ((el = (TGFrameElement *) next())) {
1162 el->fFrame->MapSubwindows();
1163 TGFrameElement *fe = el->fFrame->GetFrameElement();
1164 if (fe) fe->fState |= kIsVisible;
1172 void TGCompositeFrame::HideFrame(TGFrame *f)
1174 TGFrameElement *el = FindFrameElement(f);
1178 el->fFrame->UnmapWindow();
1186 void TGCompositeFrame::ShowFrame(TGFrame *f)
1188 TGFrameElement *el = FindFrameElement(f);
1192 el->fFrame->MapWindow();
1200 Int_t TGCompositeFrame::GetState(TGFrame *f)
const
1202 TGFrameElement *el = FindFrameElement(f);
1213 Bool_t TGCompositeFrame::IsVisible(TGFrame *f)
const
1215 TGFrameElement *el = FindFrameElement(f);
1218 return (el->fState & kIsVisible);
1226 Bool_t TGCompositeFrame::IsArranged(TGFrame *f)
const
1228 TGFrameElement *el = FindFrameElement(f);
1231 return (el->fState & kIsArranged);
1239 void TGCompositeFrame::Layout()
1241 if (IsLayoutBroken())
return;
1242 fLayoutManager->Layout();
1248 void TGCompositeFrame::Print(Option_t *option)
const
1250 TString opt = option;
1251 if (opt.Contains(
"tree")) {
1252 TGWindow::Print(option);
1258 TString tab = option;
1260 TGFrame::Print(tab.Data());
1262 while ((el = (TGFrameElement*)next())) {
1263 el->fFrame->Print(tab.Data());
1270 void TGCompositeFrame::ChangeSubframesBackground(Pixel_t back)
1272 TGFrame::ChangeBackground(back);
1277 while ((el = (TGFrameElement*)next())) {
1278 el->fFrame->SetBackgroundColor(back);
1279 if (el->fFrame->InheritsFrom(TGCompositeFrame::Class())) {
1280 ((TGCompositeFrame*)el->fFrame)->ChangeSubframesBackground(back);
1282 fClient->NeedRedraw(el->fFrame);
1284 fClient->NeedRedraw(
this);
1290 TGFrame *TGCompositeFrame::GetFrameFromPoint(Int_t x, Int_t y)
1292 if (!Contains(x, y))
return 0;
1294 if (!fList)
return this;
1300 while ((el = (TGFrameElement *) next())) {
1302 if (el->fState & kIsVisible) {
1303 f = el->fFrame->GetFrameFromPoint(x - el->fFrame->GetX(),
1304 y - el->fFrame->GetY());
1314 Bool_t TGCompositeFrame::TranslateCoordinates(TGFrame *child, Int_t x, Int_t y,
1315 Int_t &fx, Int_t &fy)
1317 if (child ==
this) {
1323 if (!Contains(x, y))
return kFALSE;
1325 if (!fList)
return kFALSE;
1330 while ((el = (TGFrameElement *) next())) {
1331 if (el->fFrame == child) {
1332 fx = x - el->fFrame->GetX();
1333 fy = y - el->fFrame->GetY();
1335 }
else if (el->fFrame->IsComposite()) {
1336 if (((TGCompositeFrame *)el->fFrame)->TranslateCoordinates(child,
1337 x - el->fFrame->GetX(), y - el->fFrame->GetY(), fx, fy))
1347 Bool_t TGCompositeFrame::HandleDragEnter(TGFrame *)
1349 if (fClient && fClient->IsEditable() &&
1350 (fId != fClient->GetRoot()->GetId())) {
1353 if (fEditDisabled & (kEditDisable | kEditDisableLayout))
return kFALSE;
1361 TColor::Pixel2RGB(fBackground, r, g, b);
1365 Pixel_t back = TColor::RGB2Pixel(r, g, b);
1366 gVirtualX->SetWindowBackground(fId, back);
1377 Bool_t TGCompositeFrame::HandleDragLeave(TGFrame *)
1379 if (fClient && fClient->IsEditable() &&
1380 (fId != fClient->GetRoot()->GetId())) {
1382 if (fEditDisabled & (kEditDisable | kEditDisableLayout))
return kFALSE;
1384 gVirtualX->SetWindowBackground(fId, fBackground);
1395 Bool_t TGCompositeFrame::HandleDragMotion(TGFrame *)
1403 Bool_t TGCompositeFrame::HandleDragDrop(TGFrame *frame, Int_t x, Int_t y,
1406 if (fClient && fClient->IsEditable() && frame && (x >= 0) && (y >= 0) &&
1407 (x + frame->GetWidth() <= fWidth) && (y + frame->GetHeight() <= fHeight)) {
1409 if (fEditDisabled & (kEditDisable | kEditDisableLayout))
return kFALSE;
1411 frame->ReparentWindow(
this, x, y);
1412 AddFrame(frame, lo);
1426 TGMainFrame::TGMainFrame(
const TGWindow *p, UInt_t w, UInt_t h,
1427 UInt_t options) : TGCompositeFrame(p, w, h, options | kMainFrame)
1433 gVirtualX->WMDeleteNotify(fId);
1435 fBindList =
new TList;
1442 fWMWidth = (UInt_t) -1;
1443 fWMHeight = (UInt_t) -1;
1444 fWMMinWidth = (UInt_t) -1;
1445 fWMMinHeight = (UInt_t) -1;
1446 fWMMaxWidth = (UInt_t) -1;
1447 fWMMaxHeight = (UInt_t) -1;
1448 fWMWidthInc = (UInt_t) -1;
1449 fWMHeightInc = (UInt_t) -1;
1450 fWMInitState = (EInitialState) 0;
1452 gVirtualX->GrabKey(fId, gVirtualX->KeysymToKeycode(kKey_s),
1453 kKeyControlMask, kTRUE);
1454 if (p == fClient->GetDefaultRoot()) {
1455 fMWMValue = kMWMDecorAll;
1456 fMWMFuncs = kMWMFuncAll;
1457 fMWMInput = kMWMInputModeless;
1458 gVirtualX->SetMWMHints(fId, fMWMValue, fMWMFuncs, fMWMInput);
1461 if (fClient->IsEditable() && (p == fClient->GetRoot())) {
1462 TGCompositeFrame *frame;
1463 if (p && p->InheritsFrom(TGCompositeFrame::Class())) {
1464 frame = (TGCompositeFrame*)p;
1465 frame->AddFrame(
this,
new TGLayoutHints(kLHintsExpandX | kLHintsExpandY));
1468 if (gDragManager && gDragManager->IsPasting()) {
1469 gDragManager->SetPasteFrame(
this);
1475 fDNDTypeList =
new Atom_t[3];
1476 fDNDTypeList[0] = gVirtualX->InternAtom(
"application/root", kFALSE);
1477 fDNDTypeList[1] = gVirtualX->InternAtom(
"text/uri-list", kFALSE);
1478 fDNDTypeList[2] = 0;
1480 new TGDNDManager(
this, fDNDTypeList);
1487 TGMainFrame::~TGMainFrame()
1489 delete [] fDNDTypeList;
1491 fBindList->Delete();
1503 Bool_t TGMainFrame::SaveFrameAsCodeOrImage()
1505 static TString dir(
".");
1506 static Bool_t overwr = kFALSE;
1510 repeat_save = kFALSE;
1513 TGMainFrame *main = (TGMainFrame*)GetMainFrame();
1514 fi.fFileTypes = gSaveMacroTypes;
1515 fi.fIniDir = StrDup(dir);
1516 fi.fOverwrite = overwr;
1517 new TGFileDialog(fClient->GetDefaultRoot(),
this, kFDSave, &fi);
1518 if (!fi.fFilename)
return kFALSE;
1520 overwr = fi.fOverwrite;
1521 TString fname = gSystem->UnixPathName(fi.fFilename);
1522 if (fname.EndsWith(
".C"))
1523 main->SaveSource(fname.Data(),
"");
1525 TImage::EImageFileTypes gtype = TImage::kUnknown;
1526 if (fname.EndsWith(
"gif")) {
1527 gtype = TImage::kGif;
1528 }
else if (fname.EndsWith(
".png")) {
1529 gtype = TImage::kPng;
1530 }
else if (fname.EndsWith(
".jpg")) {
1531 gtype = TImage::kJpeg;
1532 }
else if (fname.EndsWith(
".tiff")) {
1533 gtype = TImage::kTiff;
1534 }
else if (fname.EndsWith(
".xpm")) {
1535 gtype = TImage::kXpm;
1537 if (gtype != TImage::kUnknown) {
1538 Int_t saver = gErrorIgnoreLevel;
1539 gErrorIgnoreLevel = kFatal;
1540 TImage *img = TImage::Create();
1542 img->FromWindow(GetId());
1543 img->WriteImage(fname, gtype);
1544 gErrorIgnoreLevel = saver;
1549 new TGMsgBox(fClient->GetDefaultRoot(),
this,
"Error...",
1550 TString::Format(
"file (%s) cannot be saved with this extension",
1551 fname.Data()), kMBIconExclamation,
1552 kMBRetry | kMBCancel, &retval);
1553 repeat_save = (retval == kMBRetry);
1556 }
while (repeat_save);
1564 Bool_t TGMainFrame::HandleKey(Event_t *event)
1568 TIter next(fBindList);
1572 while ((m = (TGMapKey *) next())) {
1573 if (m->fKeyCode == event->fCode) {
1574 w = (TGFrame *) m->fWindow;
1575 if (w->HandleKey(event))
return kTRUE;
1580 if ((event->fType == kGKeyPress) && (
event->fState & kKeyControlMask)) {
1583 gVirtualX->LookupString(event, str,
sizeof(str), keysym);
1585 if ((keysym & ~0x20) == kKey_S) {
1586 return SaveFrameAsCodeOrImage();
1595 Bool_t TGMainFrame::BindKey(
const TGWindow *w, Int_t keycode, Int_t modifier)
const
1597 TList *list = fBindList;
1600 if (fClient->IsEditable()) {
1601 TGMainFrame *main = (TGMainFrame*)GetMainFrame();
1602 list = main->GetBindList();
1607 TGMapKey *m =
new TGMapKey(keycode, (TGWindow *)w);
1609 gVirtualX->GrabKey(
id, keycode, modifier, kTRUE);
1618 void TGMainFrame::RemoveBind(
const TGWindow *, Int_t keycode, Int_t modifier)
const
1621 TIter next(fBindList);
1623 while ((m = (TGMapKey *) next())) {
1624 if (m->fKeyCode == (UInt_t) keycode) {
1625 fBindList->Remove(m);
1627 gVirtualX->GrabKey(fId, keycode, modifier, kFALSE);
1637 Bool_t TGMainFrame::HandleButton(Event_t *event)
1639 if (event->fType == kButtonRelease) {
1640 if (gDNDManager->IsDragging()) gDNDManager->Drop();
1642 return TGCompositeFrame::HandleButton(event);
1649 Bool_t TGMainFrame::HandleMotion(Event_t *event)
1651 if (gDNDManager && gDNDManager->IsDragging()) {
1652 gDNDManager->Drag(event->fXRoot, event->fYRoot,
1653 TGDNDManager::GetDNDActionCopy(), event->fTime);
1655 return TGCompositeFrame::HandleMotion(event);
1661 Bool_t TGMainFrame::HandleSelection(Event_t *event)
1663 if ((Atom_t)event->fUser[1] == TGDNDManager::GetDNDSelection()) {
1665 return gDNDManager->HandleSelection(event);
1667 return TGCompositeFrame::HandleSelection(event);
1673 Bool_t TGMainFrame::HandleSelectionRequest(Event_t *event)
1675 if ((Atom_t)event->fUser[1] == TGDNDManager::GetDNDSelection()) {
1677 return gDNDManager->HandleSelectionRequest(event);
1679 return TGCompositeFrame::HandleSelectionRequest(event);
1685 Bool_t TGMainFrame::HandleClientMessage(Event_t *event)
1687 TGCompositeFrame::HandleClientMessage(event);
1689 if ((event->fFormat == 32) && ((Atom_t)event->fUser[0] == gWM_DELETE_WINDOW) &&
1690 (event->fHandle != gROOT_MESSAGE)) {
1691 Emit(
"CloseWindow()");
1692 if (TestBit(kNotDeleted) && !TestBit(kDontCallClose))
1702 void TGMainFrame::SendCloseMessage()
1706 event.fType = kClientMessage;
1708 event.fHandle = gWM_DELETE_WINDOW;
1710 event.fWindow = GetId();
1711 event.fUser[0] = (Long_t) gWM_DELETE_WINDOW;
1717 gVirtualX->SendEvent(GetId(), &event);
1728 void TGMainFrame::CloseWindow()
1738 void TGMainFrame::DontCallClose()
1740 SetBit(kDontCallClose);
1746 void TGMainFrame::SetWindowName(
const char *name)
1749 TGWindow::SetWindowName();
1752 gVirtualX->SetWindowName(fId, (
char *)name);
1759 void TGMainFrame::SetIconName(
const char *name)
1762 gVirtualX->SetIconName(fId, (
char *)name);
1774 const TGPicture *TGMainFrame::SetIconPixmap(
const char *iconName)
1776 fIconPixmap = iconName;
1777 const TGPicture *iconPic = fClient->GetPicture(iconName);
1779 Pixmap_t pic = iconPic->GetPicture();
1780 gVirtualX->SetIconPixmap(fId, pic);
1795 void TGMainFrame::SetIconPixmap(
char **xpm_array)
1797 TImage *img = TImage::Create();
1799 img->SetImageBuffer(xpm_array, TImage::kXpm);
1800 Pixmap_t pic = img->GetPixmap();
1802 gVirtualX->SetIconPixmap(fId, pic);
1804 Warning(
"SetIconPixmap",
"Failed to set window icon from xpm array.");
1814 void TGMainFrame::SetClassHints(
const char *className,
const char *resourceName)
1816 fClassName = className;
1817 fResourceName = resourceName;
1818 gVirtualX->SetClassHints(fId, (
char *)className, (
char *)resourceName);
1824 void TGMainFrame::SetMWMHints(UInt_t value, UInt_t funcs, UInt_t input)
1826 if (fClient->IsEditable() && (fParent == fClient->GetRoot()))
return;
1831 gVirtualX->SetMWMHints(fId, value, funcs, input);
1837 void TGMainFrame::SetWMPosition(Int_t x, Int_t y)
1839 if (fClient->IsEditable() && (fParent == fClient->GetRoot()))
return;
1843 gVirtualX->SetWMPosition(fId, x, y);
1849 void TGMainFrame::SetWMSize(UInt_t w, UInt_t h)
1851 if (fClient->IsEditable() && (fParent == fClient->GetRoot()))
return;
1855 gVirtualX->SetWMSize(fId, w, h);
1862 void TGMainFrame::SetWMSizeHints(UInt_t wmin, UInt_t hmin,
1863 UInt_t wmax, UInt_t hmax,
1864 UInt_t winc, UInt_t hinc)
1866 if (fClient->IsEditable() && (fParent == fClient->GetRoot()))
return;
1868 fMinWidth = fWMMinWidth = wmin;
1869 fMinHeight = fWMMinHeight = hmin;
1870 fMaxWidth = fWMMaxWidth = wmax;
1871 fMaxHeight = fWMMaxHeight = hmax;
1873 fWMHeightInc = hinc;
1874 gVirtualX->SetWMSizeHints(fId, wmin, hmin, wmax, hmax, winc, hinc);
1880 void TGMainFrame::SetWMState(EInitialState state)
1882 if (fClient->IsEditable() && (fParent == fClient->GetRoot()))
return;
1884 fWMInitState = state;
1885 gVirtualX->SetWMState(fId, state);
1893 TGTransientFrame::TGTransientFrame(
const TGWindow *p,
const TGWindow *main,
1894 UInt_t w, UInt_t h, UInt_t options)
1895 : TGMainFrame(p, w, h, options | kTransientFrame)
1898 if (!fMain && gClient)
1899 fMain = gClient->GetRoot();
1902 gVirtualX->SetWMTransientHint(fId, fMain->GetId());
1913 void TGTransientFrame::CenterOnParent(Bool_t croot, EPlacement pos)
1915 Int_t x=0, y=0, ax, ay;
1918 UInt_t dw = fClient->GetDisplayWidth();
1919 UInt_t dh = fClient->GetDisplayHeight();
1925 x = (Int_t)(((TGFrame *) fMain)->GetWidth() - fWidth) >> 1;
1926 y = (Int_t)(((TGFrame *) fMain)->GetHeight() - fHeight) >> 1;
1929 x = (Int_t)(((TGFrame *) fMain)->GetWidth() - (fWidth >> 1));
1930 y = (Int_t)(((TGFrame *) fMain)->GetHeight() - fHeight) >> 1;
1933 x = (Int_t)(-1 * (Int_t)(fWidth >> 1));
1934 y = (Int_t)(((TGFrame *) fMain)->GetHeight() - fHeight) >> 1;
1937 x = (Int_t)(((TGFrame *) fMain)->GetWidth() - fWidth) >> 1;
1938 y = (Int_t)(-1 * (Int_t)(fHeight >> 1));
1941 x = (Int_t)(((TGFrame *) fMain)->GetWidth() - fWidth) >> 1;
1942 y = (Int_t)(((TGFrame *) fMain)->GetHeight() - (fHeight >> 1));
1945 x = (Int_t)(-1 * (Int_t)(fWidth >> 1));
1946 y = (Int_t)(-1 * (Int_t)(fHeight >> 1));
1949 x = (Int_t)(((TGFrame *) fMain)->GetWidth() - (fWidth >> 1));
1950 y = (Int_t)(-1 * (Int_t)(fHeight >> 1));
1953 x = (Int_t)(-1 * (Int_t)(fWidth >> 1));
1954 y = (Int_t)(((TGFrame *) fMain)->GetHeight() - (fHeight >> 1));
1957 x = (Int_t)(((TGFrame *) fMain)->GetWidth() - (fWidth >> 1));
1958 y = (Int_t)(((TGFrame *) fMain)->GetHeight() - (fHeight >> 1));
1962 gVirtualX->TranslateCoordinates(fMain->GetId(), GetParent()->GetId(),
1963 x, y, ax, ay, wdummy);
1964 if (!gVirtualX->InheritsFrom(
"TGWin32")) {
1967 else if (ax + fWidth + 10 > dw)
1968 ax = dw - fWidth - 10;
1972 else if (ay + fHeight + 50 > dh)
1973 ay = dh - fHeight - 50;
1980 x = (dw - fWidth) >> 1;
1981 y = (dh - fHeight) >> 1;
1984 x = dw - (fWidth >> 1);
1985 y = (dh - fHeight) >> 1;
1988 x = -1 * (Int_t)(fWidth >> 1);
1989 y = (dh - fHeight) >> 1;
1992 x = (dw - fWidth) >> 1;
1993 y = -1 * (Int_t)(fHeight >> 1);
1996 x = (dw - fWidth) >> 1;
1997 y = dh - (fHeight >> 1);
2000 x = -1 * (Int_t)(fWidth >> 1);
2001 y = -1 * (Int_t)(fHeight >> 1);
2004 x = dw - (fWidth >> 1);
2005 y = -1 * (Int_t)(fHeight >> 1);
2008 x = -1 * (Int_t)(fWidth >> 1);
2009 y = dh - (fHeight >> 1);
2012 x = dw - (fWidth >> 1);
2013 y = dh - (fHeight >> 1);
2027 SetWMPosition(ax, ay);
2034 TGGroupFrame::TGGroupFrame(
const TGWindow *p, TGString *title,
2035 UInt_t options, GContext_t norm,
2036 FontStruct_t font, Pixel_t back) :
2037 TGCompositeFrame(p, 1, 1, options, back)
2043 fHasOwnFont = kFALSE;
2045 int max_ascent, max_descent;
2046 gVirtualX->GetFontProperties(fFontStruct, max_ascent, max_descent);
2047 fBorderWidth = max_ascent + max_descent + 1;
2053 TGGroupFrame::TGGroupFrame(
const TGWindow *p,
const char *title,
2054 UInt_t options, GContext_t norm,
2055 FontStruct_t font, Pixel_t back) :
2056 TGCompositeFrame(p, 1, 1, options, back)
2058 fText =
new TGString(!p && !title ? GetName() : title);
2062 fHasOwnFont = kFALSE;
2064 int max_ascent, max_descent;
2065 gVirtualX->GetFontProperties(fFontStruct, max_ascent, max_descent);
2066 fBorderWidth = max_ascent + max_descent + 1;
2074 TGGroupFrame::~TGGroupFrame()
2077 TGGCPool *pool = fClient->GetGCPool();
2078 TGGC *gc = pool->FindGC(fNormGC);
2087 TGDimension TGGroupFrame::GetDefaultSize()
const
2089 UInt_t tw = gVirtualX->TextWidth(fFontStruct, fText->GetString(),
2090 fText->GetLength()) + 24;
2092 TGDimension dim = TGCompositeFrame::GetDefaultSize();
2094 return tw>dim.fWidth ? TGDimension(tw, dim.fHeight) : dim;
2101 void TGGroupFrame::DoRedraw()
2103 gVirtualX->ClearArea(fId, 0, 0, fWidth, fHeight);
2113 void TGGroupFrame::SetTextColor(Pixel_t color, Bool_t local)
2115 TGGCPool *pool = fClient->GetResourcePool()->GetGCPool();
2116 TGGC *gc = pool->FindGC(fNormGC);
2119 gc = pool->GetGC((GCValues_t*)gc->GetAttributes(), kTRUE);
2120 fHasOwnFont = kTRUE;
2123 gc->SetForeground(color);
2124 fNormGC = gc->GetGC();
2126 fClient->NeedRedraw(
this);
2133 void TGGroupFrame::SetTextFont(FontStruct_t font, Bool_t local)
2135 FontH_t v = gVirtualX->GetFontHandle(font);
2140 TGGCPool *pool = fClient->GetResourcePool()->GetGCPool();
2141 TGGC *gc = pool->FindGC(fNormGC);
2144 gc = pool->GetGC((GCValues_t*)gc->GetAttributes(), kTRUE);
2145 fHasOwnFont = kTRUE;
2149 fNormGC = gc->GetGC();
2151 fClient->NeedRedraw(
this);
2158 void TGGroupFrame::SetTextFont(
const char *fontName, Bool_t local)
2160 TGFont *font = fClient->GetFont(fontName);
2163 SetTextFont(font->GetFontStruct(), local);
2171 Bool_t TGGroupFrame::HasOwnFont()
const
2182 void TGGroupFrame::DrawBorder()
2184 Int_t x, y, l, t, r, b, gl, gr, sep, max_ascent, max_descent;
2186 UInt_t tw = gVirtualX->TextWidth(fFontStruct, fText->GetString(), fText->GetLength());
2187 gVirtualX->GetFontProperties(fFontStruct, max_ascent, max_descent);
2190 t = (max_ascent + max_descent + 2) >> 1;
2195 TGLayoutManager * lm = GetLayoutManager();
2196 if ((lm->InheritsFrom(TGHorizontalLayout::Class())) ||
2197 (lm->InheritsFrom(TGMatrixLayout::Class())))
2203 UInt_t rr = 5 + (sep << 1) + tw;
2205 switch (fTitlePos) {
2207 gl = fWidth>rr ? Int_t(fWidth - rr) : 5 + sep;
2210 gl = fWidth>tw ? Int_t((fWidth - tw)>>1) - sep : 5 + sep;
2216 gr = gl + tw + (sep << 1);
2218 switch (fOptions & (kSunkenFrame | kRaisedFrame)) {
2220 gVirtualX->DrawLine(fId, GetHilightGC()(), l, t, gl, t);
2221 gVirtualX->DrawLine(fId, GetShadowGC()(), l+1, t+1, gl, t+1);
2223 gVirtualX->DrawLine(fId, GetHilightGC()(), gr, t, r-1, t);
2224 gVirtualX->DrawLine(fId, GetShadowGC()(), gr, t+1, r-2, t+1);
2226 gVirtualX->DrawLine(fId, GetHilightGC()(), r-1, t, r-1, b-1);
2227 gVirtualX->DrawLine(fId, GetShadowGC()(), r, t, r, b);
2229 gVirtualX->DrawLine(fId, GetHilightGC()(), r-1, b-1, l, b-1);
2230 gVirtualX->DrawLine(fId, GetShadowGC()(), r, b, l, b);
2232 gVirtualX->DrawLine(fId, GetHilightGC()(), l, b-1, l, t);
2233 gVirtualX->DrawLine(fId, GetShadowGC()(), l+1, b-2, l+1, t+1);
2237 gVirtualX->DrawLine(fId, GetShadowGC()(), l, t, gl, t);
2238 gVirtualX->DrawLine(fId, GetHilightGC()(), l+1, t+1, gl, t+1);
2240 gVirtualX->DrawLine(fId, GetShadowGC()(), gr, t, r-1, t);
2241 gVirtualX->DrawLine(fId, GetHilightGC()(), gr, t+1, r-2, t+1);
2243 gVirtualX->DrawLine(fId, GetShadowGC()(), r-1, t, r-1, b-1);
2244 gVirtualX->DrawLine(fId, GetHilightGC()(), r, t, r, b);
2246 gVirtualX->DrawLine(fId, GetShadowGC()(), r-1, b-1, l, b-1);
2247 gVirtualX->DrawLine(fId, GetHilightGC()(), r, b, l, b);
2249 gVirtualX->DrawLine(fId, GetShadowGC()(), l, b-1, l, t);
2250 gVirtualX->DrawLine(fId, GetHilightGC()(), l+1, b-2, l+1, t+1);
2257 fText->Draw(fId, fNormGC, x, y + max_ascent);
2264 void TGGroupFrame::SetTitle(TGString *title)
2267 Warning(
"SetTitle",
"title cannot be 0, try \"\"");
2268 title =
new TGString(
"");
2274 fClient->NeedRedraw(
this);
2280 void TGGroupFrame::SetTitle(
const char *title)
2283 Error(
"SetTitle",
"title cannot be 0, try \"\"");
2287 SetTitle(
new TGString(title));
2293 FontStruct_t TGGroupFrame::GetDefaultFontStruct()
2295 if (!fgDefaultFont && gClient)
2296 fgDefaultFont = gClient->GetResourcePool()->GetDefaultFont();
2297 return fgDefaultFont->GetFontStruct();
2303 const TGGC &TGGroupFrame::GetDefaultGC()
2305 if (!fgDefaultGC && gClient)
2306 fgDefaultGC = gClient->GetResourcePool()->GetFrameGC();
2307 return *fgDefaultGC;
2313 TGHeaderFrame::TGHeaderFrame(
const TGWindow *p, UInt_t w, UInt_t h,
2314 UInt_t options, Pixel_t back) :
2315 TGHorizontalFrame(p, w, h, options | kVerticalFrame, back)
2317 fSplitCursor = kNone;
2318 fSplitCursor = gVirtualX->CreateCursor(kArrowHor);
2319 fOverSplitter =
false;
2326 gVirtualX->GrabButton(fId, kAnyButton, kAnyModifier,
2327 kButtonPressMask | kButtonReleaseMask,
2329 AddInput(kPointerMotionMask);
2335 void TGHeaderFrame::SetColumnsInfo(Int_t nColumns, TGTextButton **colHeader,
2336 TGVFileSplitter **splitHeader)
2338 fNColumns = nColumns;
2339 fColHeader = colHeader;
2340 fSplitHeader = splitHeader;
2346 Bool_t TGHeaderFrame::HandleButton(Event_t* event)
2348 if ( event->fY > 0 &&
2349 event->fY <= (Int_t) this->GetHeight() ) {
2350 for (Int_t i = 1; i < fNColumns; ++i ) {
2351 if ( event->fX < fColHeader[i]->GetX() &&
2352 event->fX >= fColHeader[i-1]->GetX() ) {
2353 if ( fOverSplitter ) {
2354 if ( event->fX <= fColHeader[i-1]->GetX() + 5 )
2355 fSplitHeader[i-2]->HandleButton(event);
2357 fSplitHeader[i-1]->HandleButton(event);
2359 if ( event->fType == kButtonPress ) {
2360 fLastButton = i - 1;
2364 event->fX -= fColHeader[i-1]->GetX();
2365 fColHeader[i-1]->HandleButton(event);
2378 Bool_t TGHeaderFrame::HandleDoubleClick(Event_t *event)
2380 if ( event->fY > 0 &&
2381 event->fY <= (Int_t) this->GetHeight() ) {
2382 for (Int_t i = 1; i < fNColumns; ++i ) {
2383 if ( event->fX < fColHeader[i]->GetX() &&
2384 event->fX >= fColHeader[i-1]->GetX() ) {
2385 if ( fOverSplitter ) {
2386 if ( event->fX <= fColHeader[i-1]->GetX() + 5 )
2387 fSplitHeader[i-2]->HandleDoubleClick(event);
2389 fSplitHeader[i-1]->HandleDoubleClick(event);
2391 event->fX -= fColHeader[i-1]->GetX();
2392 fColHeader[i-1]->HandleDoubleClick(event);
2405 Bool_t TGHeaderFrame::HandleMotion(Event_t* event)
2407 if ( event->fY > 0 &&
2408 event->fY <= (Int_t) this->GetHeight() ) {
2409 Bool_t inMiddle =
false;
2411 for (Int_t i = 1; i < fNColumns; ++i ) {
2412 if ( event->fX > fColHeader[i]->GetX() - 5 &&
2413 event->fX < fColHeader[i]->GetX() + 5 ) {
2416 if ( event->fX < fColHeader[i]->GetX() &&
2417 event->fX >= fColHeader[i-1]->GetX() ) {
2418 fOverButton = i - 1;
2421 fOverSplitter = inMiddle;
2422 if ( fOverSplitter ) {
2423 gVirtualX->SetCursor(fId, fSplitCursor);
2426 gVirtualX->SetCursor(fId, kNone);
2435 void TGFrame::SaveUserColor(std::ostream &out, Option_t *option)
2439 if (gROOT->ClassSaved(TGFrame::Class())) {
2444 out <<
" ULong_t ucolor; // will reflect user color changes" << std::endl;
2447 if (option && !strcmp(option,
"slider"))
2448 ucolor = GetDefaultFrameBackground();
2450 ucolor = GetBackground();
2451 if ((ucolor != fgUserColor) || (ucolor == GetWhitePixel())) {
2452 const char *ucolorname = TColor::PixelAsHexString(ucolor);
2453 out <<
" gClient->GetColorByName(" << quote << ucolorname << quote
2454 <<
",ucolor);" << std::endl;
2455 fgUserColor = ucolor;
2462 TString TGFrame::GetOptionString()
const
2466 if (!GetOptions()) {
2467 options =
"kChildFrame";
2469 if (fOptions & kMainFrame) {
2470 if (options.Length() == 0) options =
"kMainFrame";
2471 else options +=
" | kMainFrame";
2473 if (fOptions & kVerticalFrame) {
2474 if (options.Length() == 0) options =
"kVerticalFrame";
2475 else options +=
" | kVerticalFrame";
2477 if (fOptions & kHorizontalFrame) {
2478 if (options.Length() == 0) options =
"kHorizontalFrame";
2479 else options +=
" | kHorizontalFrame";
2481 if (fOptions & kSunkenFrame) {
2482 if (options.Length() == 0) options =
"kSunkenFrame";
2483 else options +=
" | kSunkenFrame";
2485 if (fOptions & kRaisedFrame) {
2486 if (options.Length() == 0) options =
"kRaisedFrame";
2487 else options +=
" | kRaisedFrame";
2489 if (fOptions & kDoubleBorder) {
2490 if (options.Length() == 0) options =
"kDoubleBorder";
2491 else options +=
" | kDoubleBorder";
2493 if (fOptions & kFitWidth) {
2494 if (options.Length() == 0) options =
"kFitWidth";
2495 else options +=
" | kFitWidth";
2497 if (fOptions & kFixedWidth) {
2498 if (options.Length() == 0) options =
"kFixedWidth";
2499 else options +=
" | kFixedWidth";
2501 if (fOptions & kFitHeight) {
2502 if (options.Length() == 0) options =
"kFitHeight";
2503 else options +=
" | kFitHeight";
2505 if (fOptions & kFixedHeight) {
2506 if (options.Length() == 0) options =
"kFixedHeight";
2507 else options +=
" | kFixedHeight";
2509 if (fOptions & kOwnBackground) {
2510 if (options.Length() == 0) options =
"kOwnBackground";
2511 else options +=
" | kOwnBackground";
2513 if (fOptions & kTransientFrame) {
2514 if (options.Length() == 0) options =
"kTransientFrame";
2515 else options +=
" | kTransientFrame";
2517 if (fOptions & kTempFrame) {
2518 if (options.Length() == 0) options =
"kTempFrame";
2519 else options +=
" | kTempFrame";
2528 TString TGMainFrame::GetMWMvalueString()
const
2533 if (fMWMValue & kMWMDecorAll) {
2534 if (hints.Length() == 0) hints =
"kMWMDecorAll";
2535 else hints +=
" | kMWMDecorAll";
2537 if (fMWMValue & kMWMDecorBorder) {
2538 if (hints.Length() == 0) hints =
"kMWMDecorBorder";
2539 else hints +=
" | kMWMDecorBorder";
2541 if (fMWMValue & kMWMDecorResizeH) {
2542 if (hints.Length() == 0) hints =
"kMWMDecorResizeH";
2543 else hints +=
" | kMWMDecorResizeH";
2545 if (fMWMValue & kMWMDecorTitle) {
2546 if (hints.Length() == 0) hints =
"kMWMDecorTitle";
2547 else hints +=
" | kMWMDecorTitle";
2549 if (fMWMValue & kMWMDecorMenu) {
2550 if (hints.Length() == 0) hints =
"kMWMDecorMenu";
2551 else hints +=
" | kMWMDecorMenu";
2553 if (fMWMValue & kMWMDecorMinimize) {
2554 if (hints.Length() == 0) hints =
"kMWMDecorMinimize";
2555 else hints +=
" | kMWMDecorMinimize";
2557 if (fMWMValue & kMWMDecorMaximize) {
2558 if (hints.Length() == 0) hints =
"kMWMDecorMaximize";
2559 else hints +=
" | kMWMDecorMaximize";
2568 TString TGMainFrame::GetMWMfuncString()
const
2574 if (fMWMFuncs & kMWMFuncAll) {
2575 if (hints.Length() == 0) hints =
"kMWMFuncAll";
2576 else hints +=
" | kMWMFuncAll";
2578 if (fMWMFuncs & kMWMFuncResize) {
2579 if (hints.Length() == 0) hints =
"kMWMFuncResize";
2580 else hints +=
" | kMWMFuncResize";
2582 if (fMWMFuncs & kMWMFuncMove) {
2583 if (hints.Length() == 0) hints =
"kMWMFuncMove";
2584 else hints +=
" | kMWMFuncMove";
2586 if (fMWMFuncs & kMWMFuncMinimize) {
2587 if (hints.Length() == 0) hints =
"kMWMFuncMinimize";
2588 else hints +=
" | kMWMFuncMinimize";
2590 if (fMWMFuncs & kMWMFuncMaximize) {
2591 if (hints.Length() == 0) hints =
"kMWMFuncMaximize";
2592 else hints +=
" | kMWMFuncMaximize";
2594 if (fMWMFuncs & kMWMFuncClose) {
2595 if (hints.Length() == 0) hints =
"kMWMFuncClose";
2596 else hints +=
" | kMWMFuncClose";
2605 TString TGMainFrame::GetMWMinpString()
const
2609 if (fMWMInput == 0) hints =
"kMWMInputModeless";
2611 if (fMWMInput == 1) hints =
"kMWMInputPrimaryApplicationModal";
2613 if (fMWMInput == 2) hints =
"kMWMInputSystemModal";
2615 if (fMWMInput == 3) hints =
"kMWMInputFullApplicationModal";
2623 void TGCompositeFrame::SavePrimitiveSubframes(std::ostream &out, Option_t *option )
2626 out <<
" " << GetName() <<
"->SetLayoutBroken(kTRUE);" << std::endl;
2633 static TGHSplitter *hsplit = 0;
2634 static TGVSplitter *vsplit = 0;
2638 TString signal_name, slot_name;
2642 while ((el = (TGFrameElement *) next())) {
2647 if ((!(el->fState & kIsVisible)) && (el->fFrame->GetParent() !=
this))
2652 if (el->fFrame->InheritsFrom(
"TGVSplitter")) {
2653 vsplit = (TGVSplitter *)el->fFrame;
2654 if (vsplit->GetLeft())
2657 else if (el->fFrame->InheritsFrom(
"TGHSplitter")) {
2658 hsplit = (TGHSplitter *)el->fFrame;
2659 if (hsplit->GetAbove())
2662 el->fFrame->SavePrimitive(out, option);
2663 out <<
" " << GetName() <<
"->AddFrame(" << el->fFrame->GetName();
2664 el->fLayout->SavePrimitive(out, option);
2665 out <<
");"<< std::endl;
2666 if (IsLayoutBroken()) {
2667 out <<
" " << el->fFrame->GetName() <<
"->MoveResize(";
2668 out << el->fFrame->GetX() <<
"," << el->fFrame->GetY() <<
",";
2669 out << el->fFrame->GetWidth() <<
"," << el->fFrame->GetHeight();
2670 out <<
");" << std::endl;
2677 if (vsplit && el->fFrame == vsplit->GetFrame()) {
2678 out <<
" " << vsplit->GetName() <<
"->SetFrame(" << vsplit->GetFrame()->GetName();
2679 if (vsplit->GetLeft()) out <<
",kTRUE);" << std::endl;
2680 else out <<
",kFALSE);"<< std::endl;
2683 if (hsplit && el->fFrame == hsplit->GetFrame()) {
2684 out <<
" " << hsplit->GetName() <<
"->SetFrame(" << hsplit->GetFrame()->GetName();
2685 if (hsplit->GetAbove()) out <<
",kTRUE);" << std::endl;
2686 else out <<
",kFALSE);"<< std::endl;
2690 if (!(el->fState & kIsVisible)) {
2691 gListOfHiddenFrames->Add(el->fFrame);
2695 signalslist = (TList*)el->fFrame->GetListOfSignals();
2696 if (!signalslist)
continue;
2697 connlist = (TList*)signalslist->Last();
2699 conn = (TQConnection*)connlist->Last();
2701 signal_name = connlist->GetName();
2702 slot_name = conn->GetName();
2703 Int_t eq = slot_name.First(
'=');
2704 Int_t rb = slot_name.First(
')');
2706 slot_name.Remove(eq, rb-eq);
2707 out <<
" " << el->fFrame->GetName() <<
"->Connect(" << quote << signal_name
2708 << quote <<
", 0, 0, " << quote << slot_name << quote <<
");" << std::endl;
2710 TList *lsl = (TList *)gROOT->GetListOfSpecials()->FindObject(
"ListOfSlots");
2712 TObjString *slotel = (TObjString *)lsl->FindObject(slot_name);
2714 lsl->Add(
new TObjString(slot_name));
2725 void TGCompositeFrame::SavePrimitive(std::ostream &out, Option_t *option )
2727 if (fBackground != GetDefaultFrameBackground()) SaveUserColor(out, option);
2729 if (!strcmp(GetName(),
"")) {
2730 SetName(Form(
"fCompositeframe%d",fgCounter));
2734 out << std::endl <<
" // composite frame" << std::endl;
2735 out <<
" TGCompositeFrame *";
2736 out << GetName() <<
" = new TGCompositeFrame(" << fParent->GetName()
2737 <<
"," << GetWidth() <<
"," << GetHeight();
2739 if (fBackground == GetDefaultFrameBackground()) {
2740 if (!GetOptions()) {
2741 out <<
");" << std::endl;
2743 out <<
"," << GetOptionString() <<
");" << std::endl;
2746 out <<
"," << GetOptionString() <<
",ucolor);" << std::endl;
2748 if (option && strstr(option,
"keep_names"))
2749 out <<
" " << GetName() <<
"->SetName(\"" << GetName() <<
"\");" << std::endl;
2754 TGLayoutManager *lm = GetLayoutManager();
2755 if ((GetOptions() & kHorizontalFrame) &&
2756 (lm->InheritsFrom(TGHorizontalLayout::Class()))) {
2758 }
else if ((GetOptions() & kVerticalFrame) &&
2759 (lm->InheritsFrom(TGVerticalLayout::Class()))) {
2762 out <<
" " << GetName() <<
"->SetLayoutManager(";
2763 lm->SavePrimitive(out, option);
2764 out <<
");"<< std::endl;
2767 SavePrimitiveSubframes(out, option);
2773 void TGMainFrame::SaveSource(
const char *filename, Option_t *option)
2776 TString opt = option;
2777 TBits *bc =
new TBits();
2778 TClass *c1, *c2, *c3;
2781 TIter nextc1(gROOT->GetListOfClasses());
2783 while((c1 = (TClass *)nextc1())) {
2786 c1->ResetBit(TClass::kClassSaved);
2788 TIter nextc2(gROOT->GetListOfClasses());
2789 while ((c2 = (TClass *)nextc2())) {
2790 if (c1==c2)
continue;
2792 c3 = c2->GetBaseClass(c1);
2794 bc->SetBitNumber(k, kTRUE);
2802 TList *ilist =
new TList();
2803 ilist->SetName(
"ListOfIncludes");
2804 gROOT->GetListOfSpecials()->Add(ilist);
2808 TIter nextdo(gROOT->GetListOfClasses());
2809 while ((c2 = (TClass *)nextdo())) {
2811 if (bc->TestBitNumber(k) == 0 && c2->InheritsFrom(TGObject::Class()) == 1) {
2815 iname = c2->GetDeclFileName();
2816 if (iname[0] && strstr(iname,
".h")) {
2817 const char *lastsl = strrchr(iname,
'/');
2818 if (lastsl) iname = lastsl + 1;
2819 char *tname =
new char[strlen(iname)+1];
2821 while (*iname !=
'.') {
2827 TObjString *iel = (TObjString *)ilist->FindObject(tname);
2829 ilist->Add(
new TObjString(tname));
2833 if (strstr(tname,
"TRootCanvas")) {
2834 if (!ilist->FindObject(
"TGDockableFrame"))
2835 ilist->Add(
new TObjString(
"TGDockableFrame"));
2836 if (!ilist->FindObject(
"TG3DLine"))
2837 ilist->Add(
new TObjString(
"TG3DLine"));
2849 TString ff = filename && strlen(filename) ? filename :
"Rootappl.C";
2852 const char *fname = gSystem->BaseName(ff.Data());
2853 Int_t lenfname = strlen(fname);
2854 char *sname =
new char[lenfname+1];
2857 while ((*fname !=
'.') && (i < lenfname)) {
2865 out.open(ff.Data(), std::ios::out);
2867 Error(
"SaveSource",
"cannot open file: %s", ff.Data());
2874 ilist = (TList *)gROOT->GetListOfSpecials()->FindObject(
"ListOfIncludes");
2883 out <<
"// Mainframe macro generated from application: "<< gApplication->Argv(0) << std::endl;
2884 out <<
"// By ROOT version "<< gROOT->GetVersion() <<
" on "<<t.AsSQLString()<< std::endl;
2888 while((inc = (TObjString *)nexti())) {
2889 out <<
"#ifndef ROOT_" << inc->GetString() << std::endl;
2890 out <<
"#include " << quote << inc->GetString() <<
".h" << quote << std::endl;
2891 out <<
"#endif" << std::endl;
2892 if (strstr(inc->GetString(),
"TRootEmbeddedCanvas")) {
2893 out <<
"#ifndef ROOT_TCanvas" << std::endl;
2894 out <<
"#include " << quote <<
"TCanvas.h" << quote << std::endl;
2895 out <<
"#endif" << std::endl;
2898 out << std::endl <<
"#include " << quote <<
"Riostream.h" << quote << std::endl;
2900 gROOT->GetListOfSpecials()->Remove(ilist);
2907 out <<
"void " << sname <<
"()" << std::endl;
2908 out <<
"{"<< std::endl;
2911 gListOfHiddenFrames->Clear();
2914 TList *lSlots =
new TList;
2915 lSlots->SetName(
"ListOfSlots");
2916 gROOT->GetListOfSpecials()->Add(lSlots);
2918 TGMainFrame::SavePrimitive(out, option);
2920 if (strlen(fClassName) || strlen(fResourceName)) {
2921 out <<
" " << GetName() <<
"->SetClassHints(" << quote << fClassName
2922 << quote <<
"," << quote << fResourceName << quote <<
");" << std::endl;
2925 GetMWMHints(fMWMValue, fMWMFuncs, fMWMInput);
2926 if (fMWMValue || fMWMFuncs || fMWMInput) {
2927 out <<
" " << GetName() <<
"->SetMWMHints(";
2928 out << GetMWMvalueString() <<
"," << std::endl;
2930 out << GetMWMfuncString() <<
"," << std::endl;
2932 out << GetMWMinpString() <<
");"<< std::endl;
2940 GetWMSize(fWMWidth, fWMHeight);
2941 if (fWMWidth != UInt_t(-1) || fWMHeight != UInt_t(-1)) {
2942 out <<
" "<<GetName()<<
"->SetWMSize("<<fWMWidth<<
","<<fWMHeight<<
");"<<std::endl;
2945 GetWMSizeHints(fWMMinWidth, fWMMinHeight, fWMMaxWidth, fWMMaxHeight, fWMWidthInc, fWMHeightInc);
2946 if (fWMMinWidth != UInt_t(-1) || fWMMinHeight != UInt_t(-1) ||
2947 fWMMaxWidth != UInt_t(-1) || fWMMaxHeight != UInt_t(-1) ||
2948 fWMWidthInc != UInt_t(-1) || fWMHeightInc != UInt_t(-1)) {
2949 out <<
" "<<GetName()<<
"->SetWMSizeHints("<<fWMMinWidth<<
","<<fWMMinHeight
2950 <<
","<<fWMMaxWidth<<
","<<fWMMaxHeight
2951 <<
","<<fWMWidthInc<<
","<<fWMHeightInc <<
");"<<std::endl;
2954 out <<
" " <<GetName()<<
"->MapSubwindows();" << std::endl;
2956 TIter nexth(gListOfHiddenFrames);
2958 while ((fhidden = (TGFrame*)nexth())) {
2959 out <<
" " <<fhidden->GetName()<<
"->UnmapWindow();" << std::endl;
2963 gListOfHiddenFrames->Clear();
2965 Bool_t usexy = kFALSE;
2968 TGLayoutManager * lm = GetLayoutManager();
2969 if (lm->InheritsFrom(
"TGXYLayout"))
2973 out <<
" " <<GetName()<<
"->Resize("<< GetName()<<
"->GetDefaultSize());" << std::endl;
2975 out <<
" " <<GetName()<<
"->Resize("<< GetWidth()<<
","<<GetHeight()<<
");"<<std::endl;
2977 out <<
" " <<GetName()<<
"->MapWindow();" <<std::endl;
2979 GetWMPosition(fWMX, fWMY);
2980 if ((fWMX != -1) || (fWMY != -1)) {
2981 out <<
" "<<GetName()<<
"->Move("<<fWMX<<
","<<fWMY<<
");"<<std::endl;
2986 if (!usexy) out <<
" " <<GetName()<<
"->Resize("<< GetWidth()<<
","<<GetHeight()<<
");"<<std::endl;
2987 out <<
"} " << std::endl;
2990 TList *sl = (TList *)gROOT->GetListOfSpecials()->FindObject(
"ListOfSlots");
2996 while ((slobj = (TObjString*) nextsl())) {
2997 TString s = slobj->GetString();
3005 if (rb - lb > 1 && eq == -1) {
3006 p = TString::Format(
" par%d", pnumber);
3009 out <<
"void " << s << std::endl;
3010 out <<
"{" << std::endl;
3011 s = slobj->GetString();
3013 out <<
" std::cout << " << quote <<
"Slot " << s << quote
3014 <<
" <<" << p <<
" << " << quote <<
")" << quote
3015 <<
" << std::endl; " << std::endl;
3018 s.Remove(eq, rb-eq);
3019 out <<
"void " << s << std::endl;
3020 out <<
"{" << std::endl;
3021 out <<
" std::cout << " << quote <<
"Slot " << s
3022 << quote <<
" << std::endl; " << std::endl;
3024 out <<
"void " << slobj->GetString() << std::endl;
3025 out <<
"{" << std::endl;
3026 out <<
" std::cout << " << quote <<
"Slot " << slobj->GetString()
3027 << quote <<
" << std::endl; " << std::endl;
3030 out <<
"}" << std::endl;
3032 gROOT->GetListOfSpecials()->Remove(sl);
3038 if (!opt.Contains(
"quiet"))
3039 printf(
" C++ macro file %s has been generated\n", gSystem->BaseName(ff.Data()));
3043 while((c1=(TClass*)nextc1())) {
3044 c1->ResetBit(TClass::kClassSaved);
3051 void TGMainFrame::SavePrimitive(std::ostream &out, Option_t *option )
3053 if (fParent != gClient->GetDefaultRoot()) {
3054 fOptions &= ~kMainFrame;
3055 TGCompositeFrame::SavePrimitive(out, option);
3056 fOptions |= kMainFrame;
3062 out << std::endl <<
" // main frame" << std::endl;
3063 out <<
" TGMainFrame *";
3064 out << GetName() <<
" = new TGMainFrame(gClient->GetRoot(),10,10,"
3065 << GetOptionString() <<
");" <<std::endl;
3066 if (option && strstr(option,
"keep_names"))
3067 out <<
" " << GetName() <<
"->SetName(\"" << GetName() <<
"\");" << std::endl;
3072 TGLayoutManager * lm = GetLayoutManager();
3073 if ((GetOptions() & kHorizontalFrame) &&
3074 (lm->InheritsFrom(TGHorizontalLayout::Class()))) {
3076 }
else if ((GetOptions() & kVerticalFrame) &&
3077 (lm->InheritsFrom(TGVerticalLayout::Class()))) {
3080 out <<
" " << GetName() <<
"->SetLayoutManager(";
3081 lm->SavePrimitive(out, option);
3082 out <<
");"<< std::endl;
3085 SavePrimitiveSubframes(out, option);
3087 if (strlen(fWindowName)) {
3088 out <<
" " << GetName() <<
"->SetWindowName(" << quote << GetWindowName()
3089 << quote <<
");" << std::endl;
3091 if (strlen(fIconName)) {
3092 out <<
" "<<GetName()<<
"->SetIconName("<<quote<<GetIconName()<<quote<<
");"<<std::endl;
3094 if (strlen(fIconPixmap)) {
3095 out <<
" " << GetName() <<
"->SetIconPixmap(" << quote << GetIconPixmap()
3096 << quote <<
");" << std::endl;
3103 void TGHorizontalFrame::SavePrimitive(std::ostream &out, Option_t *option )
3105 if (fBackground != GetDefaultFrameBackground()) SaveUserColor(out, option);
3107 out << std::endl <<
" // horizontal frame" << std::endl;
3108 out <<
" TGHorizontalFrame *";
3109 out << GetName() <<
" = new TGHorizontalFrame(" << fParent->GetName()
3110 <<
"," << GetWidth() <<
"," << GetHeight();
3112 if (fBackground == GetDefaultFrameBackground()) {
3113 if (!GetOptions()) {
3114 out <<
");" << std::endl;
3116 out <<
"," << GetOptionString() <<
");" << std::endl;
3119 out <<
"," << GetOptionString() <<
",ucolor);" << std::endl;
3121 if (option && strstr(option,
"keep_names"))
3122 out <<
" " << GetName() <<
"->SetName(\"" << GetName() <<
"\");" << std::endl;
3127 TGLayoutManager * lm = GetLayoutManager();
3128 if ((GetOptions() & kHorizontalFrame) &&
3129 (lm->InheritsFrom(TGHorizontalLayout::Class()))) {
3131 }
else if ((GetOptions() & kVerticalFrame) &&
3132 (lm->InheritsFrom(TGVerticalLayout::Class()))) {
3135 out <<
" " << GetName() <<
"->SetLayoutManager(";
3136 lm->SavePrimitive(out, option);
3137 out <<
");"<< std::endl;
3140 SavePrimitiveSubframes(out, option);
3146 void TGVerticalFrame::SavePrimitive(std::ostream &out, Option_t *option )
3148 if (fBackground != GetDefaultFrameBackground()) SaveUserColor(out, option);
3150 out << std::endl <<
" // vertical frame" << std::endl;
3151 out <<
" TGVerticalFrame *";
3152 out << GetName() <<
" = new TGVerticalFrame(" << fParent->GetName()
3153 <<
"," << GetWidth() <<
"," << GetHeight();
3155 if (fBackground == GetDefaultFrameBackground()) {
3156 if (!GetOptions()) {
3157 out <<
");" << std::endl;
3159 out <<
"," << GetOptionString() <<
");" << std::endl;
3162 out <<
"," << GetOptionString() <<
",ucolor);" << std::endl;
3164 if (option && strstr(option,
"keep_names"))
3165 out <<
" " << GetName() <<
"->SetName(\"" << GetName() <<
"\");" << std::endl;
3170 TGLayoutManager * lm = GetLayoutManager();
3171 if ((GetOptions() & kHorizontalFrame) &&
3172 (lm->InheritsFrom(TGHorizontalLayout::Class()))) {
3174 }
else if ((GetOptions() & kVerticalFrame) &&
3175 (lm->InheritsFrom(TGVerticalLayout::Class()))) {
3178 out <<
" " << GetName() <<
"->SetLayoutManager(";
3179 lm->SavePrimitive(out, option);
3180 out <<
");"<< std::endl;
3183 SavePrimitiveSubframes(out, option);
3189 void TGFrame::SavePrimitive(std::ostream &out, Option_t *option )
3191 if (fBackground != GetDefaultFrameBackground()) SaveUserColor(out, option);
3193 out <<
" TGFrame *";
3194 out << GetName() <<
" = new TGFrame("<< fParent->GetName()
3195 <<
"," << GetWidth() <<
"," << GetHeight();
3197 if (fBackground == GetDefaultFrameBackground()) {
3198 if (!GetOptions()) {
3199 out <<
");" << std::endl;
3201 out <<
"," << GetOptionString() <<
");" << std::endl;
3204 out <<
"," << GetOptionString() <<
",ucolor);" << std::endl;
3206 if (option && strstr(option,
"keep_names"))
3207 out <<
" " << GetName() <<
"->SetName(\"" << GetName() <<
"\");" << std::endl;
3213 void TGGroupFrame::SavePrimitive(std::ostream &out, Option_t *option )
3218 option = GetName()+5;
3219 TString parGC, parFont;
3222 parFont.Form(
"%s::GetDefaultFontStruct()",IsA()->GetName());
3225 parGC.Form(
"%s::GetDefaultGC()()",IsA()->GetName());
3227 if ((GetDefaultFontStruct() != fFontStruct) || (GetDefaultGC()() != fNormGC)) {
3228 TGFont *ufont = gClient->GetResourcePool()->GetFontPool()->FindFont(fFontStruct);
3230 ufont->SavePrimitive(out, option);
3231 parFont.Form(
"ufont->GetFontStruct()");
3234 TGGC *userGC = gClient->GetResourcePool()->GetGCPool()->FindGC(fNormGC);
3236 userGC->SavePrimitive(out, option);
3237 parGC.Form(
"uGC->GetGC()");
3241 if (fBackground != GetDefaultFrameBackground()) SaveUserColor(out, option);
3243 out << std::endl <<
" // " << quote << GetTitle() << quote <<
" group frame" << std::endl;
3244 out <<
" TGGroupFrame *";
3245 out << GetName() <<
" = new TGGroupFrame("<<fParent->GetName()
3246 <<
"," << quote << GetTitle() << quote;
3248 if (fBackground == GetDefaultFrameBackground()) {
3249 if (fFontStruct == GetDefaultFontStruct()) {
3250 if (fNormGC == GetDefaultGC()()) {
3251 if (GetOptions() & kVerticalFrame) {
3252 out <<
");" << std::endl;
3254 out <<
"," << GetOptionString() <<
");" << std::endl;
3257 out <<
"," << GetOptionString() <<
"," << parGC.Data() <<
");" << std::endl;
3260 out <<
"," << GetOptionString() <<
"," << parGC.Data() <<
"," << parFont.Data() <<
");" << std::endl;
3263 out <<
"," << GetOptionString() <<
"," << parGC.Data() <<
"," << parFont.Data() <<
",ucolor);" << std::endl;
3265 if (option && strstr(option,
"keep_names"))
3266 out <<
" " << GetName() <<
"->SetName(\"" << GetName() <<
"\");" << std::endl;
3268 if (GetTitlePos() != -1)
3269 out <<
" " << GetName() <<
"->SetTitlePos(";
3270 if (GetTitlePos() == 0)
3271 out <<
"TGGroupFrame::kCenter);" << std::endl;
3272 if (GetTitlePos() == 1)
3273 out <<
"TGGroupFrame::kRight);" << std::endl;
3275 SavePrimitiveSubframes(out, option);
3278 out <<
" " << GetName() <<
"->SetLayoutManager(";
3281 GetLayoutManager()->SavePrimitive(out, option);
3282 out <<
");"<< std::endl;
3284 out <<
" " << GetName() <<
"->Resize(" << GetWidth() <<
","
3285 << GetHeight() <<
");" << std::endl;
3292 void TGTransientFrame::SaveSource(
const char *filename, Option_t *option)
3296 TString opt = option;
3297 TBits *bc =
new TBits();
3298 TClass *c1, *c2, *c3;
3301 TIter nextc1(gROOT->GetListOfClasses());
3302 while((c1 = (TClass *)nextc1())) {
3305 c1->ResetBit(TClass::kClassSaved);
3307 TIter nextc2(gROOT->GetListOfClasses());
3308 while ((c2 = (TClass *)nextc2())) {
3309 if (c1==c2)
continue;
3311 c3 = c2->GetBaseClass(c1);
3313 bc->SetBitNumber(k, kTRUE);
3321 TList *ilist =
new TList();
3322 ilist->SetName(
"ListOfIncludes");
3323 gROOT->GetListOfSpecials()->Add(ilist);
3327 TIter nextdo(gROOT->GetListOfClasses());
3328 while ((c2 = (TClass *)nextdo())) {
3330 if (bc->TestBitNumber(k) == 0 && c2->InheritsFrom(TGObject::Class()) == 1) {
3334 iname = c2->GetDeclFileName();
3335 if (iname[0] && strstr(iname,
".h")) {
3336 const char *lastsl = strrchr(iname,
'/');
3337 if (lastsl) iname = lastsl + 1;
3338 char *tname =
new char[strlen(iname)+1];
3340 while (*iname !=
'.') {
3346 TObjString *iel = (TObjString *)ilist->FindObject(tname);
3348 ilist->Add(
new TObjString(tname));
3360 TString ff = filename && strlen(filename) ? filename :
"Rootdlog.C";
3363 const char *fname = gSystem->BaseName(ff.Data());
3364 Int_t lenfname = strlen(fname);
3365 char *sname =
new char[lenfname+1];
3368 while ((*fname !=
'.') && (i < lenfname)) {
3376 out.open(ff.Data(), std::ios::out);
3378 Error(
"SaveSource",
"cannot open file: %s", ff.Data());
3385 ilist = (TList *)gROOT->GetListOfSpecials()->FindObject(
"ListOfIncludes");
3394 out <<
"// Dialog macro generated from application: "<< gApplication->Argv(0) << std::endl;
3395 out <<
"// By ROOT version "<< gROOT->GetVersion() <<
" on "<<t.AsSQLString()<< std::endl;
3398 out <<
"#if !defined( __CINT__) || defined (__MAKECINT__)" << std::endl << std::endl;
3401 while((inc = (TObjString *)nexti())) {
3402 out <<
"#ifndef ROOT_"<< inc->GetString() << std::endl;
3403 out <<
"#include "<< quote << inc->GetString() <<
".h"<< quote << std::endl;
3404 out <<
"#endif" << std::endl;
3405 if (strstr(inc->GetString(),
"TRootEmbeddedCanvas")) {
3406 out <<
"#ifndef ROOT_TCanvas"<< std::endl;
3407 out <<
"#include "<< quote <<
"TCanvas.h"<< quote << std::endl;
3408 out <<
"#endif" << std::endl;
3411 out << std::endl <<
"#include " << quote <<
"Riostream.h" << quote << std::endl;
3412 out << std::endl <<
"#endif" << std::endl;
3414 gROOT->GetListOfSpecials()->Remove(ilist);
3421 out <<
"void " << sname <<
"()" << std::endl;
3425 out <<
"{"<< std::endl;
3427 gListOfHiddenFrames->Clear();
3430 TList *lSlots =
new TList;
3431 lSlots->SetName(
"ListOfSlots");
3432 gROOT->GetListOfSpecials()->Add(lSlots);
3434 TGTransientFrame::SavePrimitive(out, option);
3436 if (strlen(fClassName) || strlen(fResourceName)) {
3437 out<<
" "<<GetName()<<
"->SetClassHints("<<quote<<fClassName<<quote
3438 <<
"," <<quote<<fResourceName<<quote
3442 GetMWMHints(fMWMValue, fMWMFuncs, fMWMInput);
3443 if (fMWMValue || fMWMFuncs || fMWMInput) {
3444 out <<
" " << GetName() <<
"->SetMWMHints(";
3445 out << GetMWMvalueString() <<
"," << std::endl;
3447 out << GetMWMfuncString() <<
"," << std::endl;
3449 out << GetMWMinpString() <<
");"<< std::endl;
3452 GetWMPosition(fWMX, fWMY);
3453 if ((fWMX != -1) || (fWMY != -1)) {
3454 out <<
" "<<GetName()<<
"->SetWMPosition("<<fWMX<<
","<<fWMY<<
");"<<std::endl;
3457 GetWMSize(fWMWidth, fWMHeight);
3458 if (fWMWidth != UInt_t(-1) || fWMHeight != UInt_t(-1)) {
3459 out <<
" "<<GetName()<<
"->SetWMSize("<<fWMWidth<<
","<<fWMHeight<<
");"<<std::endl;
3462 GetWMSizeHints(fWMMinWidth,fWMMinHeight,fWMMaxWidth,fWMMaxHeight,fWMWidthInc,fWMHeightInc);
3463 if (fWMMinWidth != UInt_t(-1) || fWMMinHeight != UInt_t(-1) ||
3464 fWMMaxWidth != UInt_t(-1) || fWMMaxHeight != UInt_t(-1) ||
3465 fWMWidthInc != UInt_t(-1) || fWMHeightInc != UInt_t(-1)) {
3467 out <<
" "<<GetName()<<
"->SetWMSizeHints("<<fWMMinWidth<<
","<<fWMMinHeight
3468 <<
","<<fWMMaxWidth<<
","<<fWMMaxHeight <<
","<<fWMWidthInc<<
","<<fWMHeightInc
3472 GetWMPosition(fWMX, fWMY);
3473 if ((fWMX != -1) || (fWMY != -1)) {
3474 out <<
" "<<GetName()<<
"->Move("<<fWMX<<
","<<fWMY<<
");"<<std::endl;
3477 out <<
" " <<GetName()<<
"->MapSubwindows();" << std::endl;
3479 TIter nexth(gListOfHiddenFrames);
3481 while ((fhidden = (TGFrame*)nexth())) {
3482 out <<
" " <<fhidden->GetName()<<
"->UnmapWindow();" << std::endl;
3485 gListOfHiddenFrames->Clear();
3487 Bool_t usexy = kFALSE;
3490 TGLayoutManager * lm = GetLayoutManager();
3491 if (lm->InheritsFrom(
"TGXYLayout"))
3495 out <<
" " <<GetName()<<
"->Resize("<< GetName()<<
"->GetDefaultSize());" << std::endl;
3497 out <<
" " <<GetName()<<
"->Resize("<< GetWidth()<<
","<<GetHeight()<<
");"<<std::endl;
3499 out <<
" " <<GetName()<<
"->MapWindow();" <<std::endl;
3500 if (!usexy) out <<
" " <<GetName()<<
"->Resize();" << std::endl;
3501 out <<
"} " << std::endl;
3504 TList *sl = (TList *)gROOT->GetListOfSpecials()->FindObject(
"ListOfSlots");
3510 while ((slobj = (TObjString*) nextsl())) {
3511 TString s = slobj->GetString();
3519 if (rb - lb > 1 && eq == -1) {
3520 p = TString::Format(
" par%d", pnumber);
3523 out <<
"void " << s << std::endl;
3524 out <<
"{" << std::endl;
3525 s = slobj->GetString();
3527 out <<
" std::cout << " << quote <<
"Slot " << s << quote
3528 <<
" <<" << p <<
" << " << quote <<
")" << quote
3529 <<
" << std::endl; " << std::endl;
3532 s.Remove(eq, rb-eq);
3533 out <<
"void " << s << std::endl;
3534 out <<
"{" << std::endl;
3535 out <<
" std::cout << " << quote <<
"Slot " << s
3536 << quote <<
" << std::endl; " << std::endl;
3538 out <<
"void " << slobj->GetString() << std::endl;
3539 out <<
"{" << std::endl;
3540 out <<
" std::cout << " << quote <<
"Slot " << slobj->GetString()
3541 << quote <<
" << std::endl; " << std::endl;
3544 out <<
"}" << std::endl;
3546 gROOT->GetListOfSpecials()->Remove(sl);
3553 if (!opt.Contains(
"quiet"))
3554 printf(
" C++ macro file %s has been generated\n", gSystem->BaseName(ff.Data()));
3558 while((c1=(TClass*)nextc1())) {
3559 c1->ResetBit(TClass::kClassSaved);
3566 void TGTransientFrame::SavePrimitive(std::ostream &out, Option_t *option )
3570 out << std::endl <<
" // transient frame" << std::endl;
3571 out <<
" TGTransientFrame *";
3572 out << GetName()<<
" = new TGTransientFrame(gClient->GetRoot(),0"
3573 <<
"," << GetWidth() <<
"," << GetHeight() <<
"," << GetOptionString() <<
");" << std::endl;
3575 if (option && strstr(option,
"keep_names"))
3576 out <<
" " << GetName() <<
"->SetName(\"" << GetName() <<
"\");" << std::endl;
3581 TGLayoutManager * lm = GetLayoutManager();
3582 if ((GetOptions() & kHorizontalFrame) &&
3583 (lm->InheritsFrom(TGHorizontalLayout::Class()))) {
3585 }
else if ((GetOptions() & kVerticalFrame) &&
3586 (lm->InheritsFrom(TGVerticalLayout::Class()))) {
3589 out <<
" " << GetName() <<
"->SetLayoutManager(";
3590 lm->SavePrimitive(out, option);
3591 out <<
");"<< std::endl;
3594 SavePrimitiveSubframes(out, option);
3596 if (strlen(fWindowName)) {
3597 out <<
" " << GetName() <<
"->SetWindowName(" << quote << GetWindowName()
3598 << quote <<
");" << std::endl;
3600 if (strlen(fIconName)) {
3601 out <<
" "<<GetName()<<
"->SetIconName("<<quote<<GetIconName()<<quote<<
");"<<std::endl;
3603 if (strlen(fIconPixmap)) {
3604 out <<
" " << GetName() <<
"->SetIconPixmap(" << quote << GetIconPixmap()
3605 << quote <<
");" << std::endl;