Logo ROOT  
Reference Guide
TGTab.cxx
Go to the documentation of this file.
1 // @(#)root/gui:$Id$
2 // Author: Fons Rademakers 13/01/98
3 
4 /*************************************************************************
5  * Copyright (C) 1995-2000, Rene Brun and Fons Rademakers. *
6  * All rights reserved. *
7  * *
8  * For the licensing terms see $ROOTSYS/LICENSE. *
9  * For the list of contributors see $ROOTSYS/README/CREDITS. *
10  *************************************************************************/
11 /**************************************************************************
12 
13  This source is based on Xclass95, a Win95-looking GUI toolkit.
14  Copyright (C) 1996, 1997 David Barth, Ricky Ralston, Hector Peraza.
15 
16  Xclass95 is free software; you can redistribute it and/or
17  modify it under the terms of the GNU Library General Public
18  License as published by the Free Software Foundation; either
19  version 2 of the License, or (at your option) any later version.
20 
21 **************************************************************************/
22 
23 //////////////////////////////////////////////////////////////////////////
24 // //
25 // TGTab, TGTabElement, TGTabLayout //
26 // //
27 // A tab widget contains a set of composite frames each with a little //
28 // tab with a name (like a set of folders with tabs). //
29 // //
30 // The TGTab is user callable. The TGTabElement and TGTabLayout are //
31 // service classes of the tab widget. //
32 // //
33 // Clicking on a tab will bring the associated composite frame to the //
34 // front and generate the following event: //
35 // kC_COMMAND, kCM_TAB, tab id, 0. //
36 // //
37 //////////////////////////////////////////////////////////////////////////
38 
39 #include "TGTab.h"
40 #include "TGResourcePool.h"
41 #include "TList.h"
42 #include "TClass.h"
43 #include "TGPicture.h"
44 #include "TVirtualX.h"
45 
46 #include <iostream>
47 
48 const TGFont *TGTab::fgDefaultFont = nullptr;
49 const TGGC *TGTab::fgDefaultGC = nullptr;
50 
54 
55 
56 ////////////////////////////////////////////////////////////////////////////////
57 /// Create a tab element. Text is adopted by tab element.
58 
60  GContext_t norm, FontStruct_t font,
61  UInt_t options, ULong_t back) :
62  TGFrame(p, w, h, options, back)
63 {
64  fClosePic = 0;
65  fClosePicD = 0;
67  fActive = kFALSE;
68  fText = text;
69  fBorderWidth = 0;
70  fTWidth = 0;
71  fNormGC = norm;
72  fFontStruct = font;
74 
75  fClosePic = fClient->GetPicture("closetab.png");
76  fClosePicD = fClient->GetPicture("closetab_d.png");
77  int max_ascent, max_descent;
78  if (fText)
80  gVirtualX->GetFontProperties(fFontStruct, max_ascent, max_descent);
81  fTHeight = max_ascent + max_descent;
83  fEnabled = kTRUE;
85 }
86 
87 ////////////////////////////////////////////////////////////////////////////////
88 /// Delete tab element.
89 
91 {
92  if (fClosePic) gClient->FreePicture(fClosePic);
93  if (fClosePicD) gClient->FreePicture(fClosePicD);
94  if (fText) delete fText;
95 }
96 
97 ////////////////////////////////////////////////////////////////////////////////
98 /// Draw little tab element.
99 
101 {
102  gVirtualX->DrawLine(fId, GetHilightGC()(), 0, fHeight-1, 0, 2);
103  gVirtualX->DrawLine(fId, GetHilightGC()(), 0, 2, 2, 0);
104  gVirtualX->DrawLine(fId, GetHilightGC()(), 2, 0, fWidth-3, 0);
105  gVirtualX->DrawLine(fId, GetShadowGC()(), fWidth-2, 1, fWidth-2, fHeight-1);
106  if (gClient->GetStyle() < 2) {
107  gVirtualX->DrawLine(fId, GetBlackGC()(), fWidth-2, 1, fWidth-1, 2);
108  gVirtualX->DrawLine(fId, GetBlackGC()(), fWidth-1, 2, fWidth-1, fHeight-2);
109  }
110  gVirtualX->DrawLine(fId, GetHilightGC()(), fWidth-1, fHeight-1, fWidth-1, fHeight-1);
111 
112  if (fText) {
113  int max_ascent, max_descent;
114  gVirtualX->GetFontProperties(fFontStruct, max_ascent, max_descent);
115  if (fEnabled) {
116  fText->Draw(fId, fNormGC, 6, max_ascent+3);
117  } else {
118  fText->Draw(fId, GetHilightGC()(), 7, max_ascent + 1);
119  fText->Draw(fId, GetShadowGC()(), 6, max_ascent);
120  }
121  }
122  if (fShowClose && fClosePic && fClosePicD) {
123  if (fEnabled && fActive)
124  fClosePic->Draw(fId, fNormGC, fTWidth+12, fHeight/2-7);
125  else
127  }
128 }
129 
130 ////////////////////////////////////////////////////////////////////////////////
131 /// Handle button event in the tab widget. Basically we only handle
132 /// button events in the small tabs.
133 
135 {
136  if (event->fType == kButtonPress) {
137  TGTab* main = (TGTab*)fParent;
138  if (main) {
139  if (fShowClose && event->fWindow == GetId() &&
140  (UInt_t)event->fX > fTWidth+12 && (UInt_t)event->fX < fTWidth+26 &&
141  (UInt_t)event->fY > fHeight/2-7 && (UInt_t)event->fY < fHeight/2+7) {
142  if (main->GetTabTab(main->GetCurrent()) == this) {
143  main->CloseTab(main->GetCurrent()); // emit signal
144  //main->RemoveTab(main->GetCurrent());
145  return kTRUE;
146  }
147  }
148  TGFrameElement *el;
149  TIter next(main->GetList());
150 
151  next(); // skip first container
152 
153  Int_t i = 0;
154  Int_t c = main->GetCurrent();
155  while ((el = (TGFrameElement *) next())) {
156  if (el->fFrame->GetId() == (Window_t)event->fWindow)
157  c = i;
158  next(); i++;
159  }
160 
161  // change tab and generate event
162  main->SetTab(c);
163  }
164  }
165  return kTRUE;
166 }
167 
168 ////////////////////////////////////////////////////////////////////////////////
169 /// Return default size of tab element.
170 
172 {
173  if (fShowClose && fClosePic && fClosePicD)
174  return TGDimension(TMath::Max(fTWidth+30, (UInt_t)45), fTHeight+6);
175  else
176  return TGDimension(TMath::Max(fTWidth+12, (UInt_t)45), fTHeight+6);
177 }
178 
179 ////////////////////////////////////////////////////////////////////////////////
180 /// Set new tab text.
181 
183 {
184  if (fText) delete fText;
185  fText = text;
186 
187  int max_ascent, max_descent;
189  gVirtualX->GetFontProperties(fFontStruct, max_ascent, max_descent);
190  fTHeight = max_ascent + max_descent;
191 
192  fClient->NeedRedraw(this);
193 }
194 
195 ////////////////////////////////////////////////////////////////////////////////
196 /// Show/hide close icon on the tab element, then apply layout
197 /// to compute correct elements size.
198 
200 {
201  TGTab* main = (TGTab*)fParent;
202  fShowClose = show;
203  if (fShowClose && fClosePic && fClosePicD)
204  Resize(TMath::Max(fTWidth+30, (UInt_t)45), fTHeight+6);
205  else
206  Resize(TMath::Max(fTWidth+12, (UInt_t)45), fTHeight+6);
207  if (main)
208  main->GetLayoutManager()->Layout();
209 }
210 
211 ////////////////////////////////////////////////////////////////////////////////
212 /// Create a tab layout manager.
213 
215 {
216  fMain = main;
217  fList = fMain->GetList();
218 }
219 
220 ////////////////////////////////////////////////////////////////////////////////
221 /// Layout the tab widget.
222 
224 {
225  Int_t i, xtab;
226  UInt_t tw;
227  UInt_t tabh = fMain->GetTabHeight(), bw = fMain->GetBorderWidth();
228  UInt_t w = fMain->GetWidth();
229  UInt_t h = fMain->GetHeight();
230 
231  xtab = 2;
232 
233  fMain->GetContainer()->MoveResize(0, tabh, w, h - tabh);
234 
235  // first frame is the container, so take next...
236  TGFrameElement *el, *elnxt;
237  TIter next(fList);
238  i = 0;
239  next(); // skip first
240  while ((el = (TGFrameElement *) next())) {
241  elnxt = (TGFrameElement *) next();
242  tw = el->fFrame->GetDefaultWidth();
243  if (i == fMain->GetCurrent()) {
244  el->fFrame->MoveResize(xtab-2, 0, tw+3, tabh+1);
245  if (elnxt) elnxt->fFrame->RaiseWindow();
246  el->fFrame->RaiseWindow();
247  } else {
248  el->fFrame->MoveResize(xtab, 2, tw, tabh-1);
249  el->fFrame->LowerWindow();
250  }
251  UInt_t nw = (w - (bw << 1));
252  if (nw > 32768) nw = 1;
253  UInt_t nh = (h - tabh - (bw << 1));
254  if (nh > 32768) nh = 1;
255  if (elnxt) {
256  elnxt->fFrame->MoveResize(bw, tabh + bw, nw, nh);
257  elnxt->fFrame->Layout();
258  }
259  xtab += (Int_t)tw;
260  i++;
261  }
262 }
263 
264 ////////////////////////////////////////////////////////////////////////////////
265 /// Get default size of tab widget.
266 
268 {
269  TGDimension dsize, dsize_te;
270  TGDimension size(0,0), size_te(0,0);
271 
272  TGFrameElement *el, *elnxt;
273  TIter next(fList);
274  next(); // skip first container
275  while ((el = (TGFrameElement *)next())) {
276  dsize_te = el->fFrame->GetDefaultSize();
277  size_te.fWidth += dsize_te.fWidth;
278  elnxt = (TGFrameElement *) next();
279  if (elnxt) {
280  dsize = elnxt->fFrame->GetDefaultSize();
281  if (size.fWidth < dsize.fWidth) size.fWidth = dsize.fWidth;
282  if (size.fHeight < dsize.fHeight) size.fHeight = dsize.fHeight;
283  }
284  }
285 
286  // check if tab elements make a larger width than the containers
287  if (size.fWidth < size_te.fWidth) size.fWidth = size_te.fWidth;
288 
289  size.fWidth += fMain->GetBorderWidth() << 1;
290  size.fHeight += fMain->GetTabHeight() + (fMain->GetBorderWidth() << 1);
291 
292  return size;
293 }
294 
295 
296 ////////////////////////////////////////////////////////////////////////////////
297 /// Create tab widget.
298 
300  GContext_t norm, FontStruct_t font,
301  UInt_t options, ULong_t back) :
302  TGCompositeFrame(p, w, h, options, back)
303 {
304  fMsgWindow = p;
305 
306  fBorderWidth = 2;
307  fCurrent = 0;
308  fRemoved = new TList;
309 
310  fNormGC = norm;
311  fFontStruct = font;
312 
313  int max_ascent, max_descent;
314  gVirtualX->GetFontProperties(fFontStruct, max_ascent, max_descent);
315  fTabh = max_ascent + max_descent + 6;
316 
317  SetLayoutManager(new TGTabLayout(this));
318 
319  // we need this in order to avoid border blinking when switching tabs...
322  AddFrame(fContainer, 0);
323 
326 }
327 
328 ////////////////////////////////////////////////////////////////////////////////
329 /// Delete tab widget. This deletes the tab windows and the containers.
330 /// The tab string is deleted by the TGTabElement dtor.
331 
333 {
334  Cleanup();
335  fRemoved->Delete();
336  delete fRemoved;
337 }
338 
339 ////////////////////////////////////////////////////////////////////////////////
340 /// Add a tab to the tab widget. Returns the new container, which
341 /// is owned by the tab widget. The text is adopted by the tab widget.
342 
344 {
345  TGTabElement *te = new TGTabElement(this, text, 50, 20, fNormGC, fFontStruct);
346  AddFrame(te, 0);
347 
348  TGCompositeFrame* cf = new TGCompositeFrame(this, fWidth, fHeight-21);
349  AddFrame(cf, 0);
351 
352  te->MapWindow();
353  cf->MapWindow();
354 
355  return cf;
356 }
357 
358 ////////////////////////////////////////////////////////////////////////////////
359 /// Add a tab to the tab widget. Returns the new container. The container
360 /// is owned by the tab widget.
361 
363 {
364  return AddTab(new TGString(text));
365 }
366 
367 ////////////////////////////////////////////////////////////////////////////////
368 /// Add a tab to the tab widget and fill it with given TGCompositeFrame.
369 
370 void TGTab::AddTab(const char *text, TGCompositeFrame *cf)
371 {
372  AddTab(new TGString(text), cf);
373 }
374 
375 ////////////////////////////////////////////////////////////////////////////////
376 /// Add a tab to the tab widget and fill it with given TGCompositeFrame.
377 
379 {
380  TGTabElement *te = new TGTabElement(this, text, 50, 20, fNormGC, fFontStruct);
381  AddFrame(te, 0);
382 
383  AddFrame(cf, 0);
385 
386  te->MapWindow();
387  cf->MapWindow();
388 }
389 
390 ////////////////////////////////////////////////////////////////////////////////
391 /// Remove container and tab of tab with index tabIndex.
392 /// Does NOT remove the container contents!
393 
394 void TGTab::RemoveTab(Int_t tabIndex, Bool_t storeRemoved)
395 {
396  if (tabIndex < 0) {
397  tabIndex = fCurrent;
398  }
399 
400  TGFrameElement *elTab, *elCont;
401  Int_t count = 0;
402 
403  // Notify (signal) for removed tab "tabIndex"
404  Removed(tabIndex);
405 
406  TIter next(fList) ;
407  next() ; // skip first container
408 
409  while ((elTab = (TGFrameElement *) next())) {
410  elCont = (TGFrameElement *) next();
411 
412  if (count == tabIndex) {
413  elCont->fFrame->UnmapWindow(); // will be destroyed later
414  TGFrame *frame = elTab->fFrame;
415  RemoveFrame(elTab->fFrame);
416  frame->DestroyWindow();
417  delete frame;
418  if (storeRemoved)
419  fRemoved->Add(elCont->fFrame); // delete only in dtor
420  RemoveFrame(elCont->fFrame);
421  if (tabIndex == fCurrent) {
422  // select another tab only if the current is the one we delete
423  SetTab(0);
424  } else
425  fCurrent--;
426  break;
427  }
428  count++;
429  }
430 
432 }
433 
434 ////////////////////////////////////////////////////////////////////////////////
435 /// Enable or disable tab.
436 
437 void TGTab::SetEnabled(Int_t tabIndex, Bool_t on)
438 {
439  TGTabElement *te = GetTabTab(tabIndex);
440  if (te) {
441  te->SetEnabled(on);
442  fClient->NeedRedraw(te);
443  }
444 }
445 
446 ////////////////////////////////////////////////////////////////////////////////
447 /// Returns true if tab is enabled.
448 
450 {
451  TGTabElement *te = GetTabTab(tabIndex);
452 
453  return te ? te->IsEnabled() : kFALSE;
454 }
455 
456 ////////////////////////////////////////////////////////////////////////////////
457 /// Make tabIdx the current tab. Utility method called by SetTab and
458 /// HandleButton().
459 
460 void TGTab::ChangeTab(Int_t tabIndex, Bool_t emit)
461 {
462  TGTabElement *te = GetTabTab(tabIndex);
463  if (!te || !te->IsEnabled()) return;
464 
465  if (tabIndex != fCurrent) {
466  if (GetTabTab(fCurrent)) {
469  }
470  TGFrameElement *el, *elnxt;
471  UInt_t tw;
472  Int_t xtab = 2;
473  Int_t count = 0;
474 
475  TIter next(fList);
476  next(); // skip first container
477 
478  fCurrent = tabIndex;
479  while ((el = (TGFrameElement *) next())) {
480  elnxt = (TGFrameElement *) next();
481  tw = el->fFrame->GetDefaultWidth();
482  if (count == fCurrent) {
483  el->fFrame->MoveResize(xtab-2, 0, tw+3, fTabh+1);
484  if (elnxt) elnxt->fFrame->RaiseWindow();
485  el->fFrame->RaiseWindow();
486  } else {
487  el->fFrame->MoveResize(xtab, 2, tw, fTabh-1);
488  el->fFrame->LowerWindow();
489  }
490  xtab += tw;
491  count++;
492  }
493  if (emit) {
497  }
500  }
501 }
502 
503 ////////////////////////////////////////////////////////////////////////////////
504 /// Brings the composite frame with the index tabIndex to the
505 /// front and generate the following event if the front tab has changed:
506 /// kC_COMMAND, kCM_TAB, tab id, 0.
507 /// Returns kFALSE if tabIndex is a not valid index
508 
510 {
511  // check if tabIndex is a valid index
512  if (tabIndex < 0)
513  return kFALSE;
514 
515  // count the tabs
516  TIter next(fList);
517  Int_t count = 0;
518  while (next())
519  count++;
520 
521  count = count / 2 - 1;
522  if (tabIndex > count)
523  return kFALSE;
524 
525  // change tab and generate event
526  ChangeTab(tabIndex, emit);
527 
528  return kTRUE;
529 }
530 
531 ////////////////////////////////////////////////////////////////////////////////
532 /// Brings the composite frame with the name to the
533 /// front and generate the following event if the front tab has changed:
534 /// kC_COMMAND, kCM_TAB, tab id, 0.
535 /// Returns kFALSE if tab with name does not exist.
536 
537 Bool_t TGTab::SetTab(const char *name, Bool_t emit)
538 {
539  TGFrameElement *el;
540  Int_t count = 0;
541  TGTabElement *tab = 0;
542 
543  TIter next(fList);
544  next(); // skip first container
545 
546  while ((el = (TGFrameElement *) next())) {
547  next(); // skip tab containter
548  tab = (TGTabElement *)el->fFrame;
549 
550  if (*(tab->GetText()) == name) {
551  // change tab and generate event
552  ChangeTab(count, emit);
553  return kTRUE;
554  }
555  count++;
556  }
557 
558  return kFALSE;
559 }
560 
561 ////////////////////////////////////////////////////////////////////////////////
562 /// Return container of tab with index tabIndex.
563 /// Return 0 in case tabIndex is out of range.
564 
566 {
567  if (tabIndex < 0) return 0;
568 
569  TGFrameElement *el;
570  Int_t count = 0;
571 
572  TIter next(fList);
573  next(); // skip first container
574 
575  while (next()) {
576  el = (TGFrameElement *) next();
577  if (el && count == tabIndex)
578  return (TGCompositeFrame *) el->fFrame;
579  count++;
580  }
581 
582  return 0;
583 }
584 
585 ////////////////////////////////////////////////////////////////////////////////
586 /// Return the tab container of tab with string name.
587 /// Returns 0 in case name is not found.
588 
590 {
591  TGFrameElement *el;
592  TGTabElement *tab = 0;
593  TGCompositeFrame *comp = 0;
594 
595  TIter next(fList);
596  next();
597 
598  while ((el = (TGFrameElement *) next())) {
599  tab = (TGTabElement *) el->fFrame;
600  el = (TGFrameElement *) next();
601  comp = (TGCompositeFrame *) el->fFrame;
602  if (*tab->GetText() == name){
603  return comp;
604  }
605  }
606 
607  return 0;
608 }
609 
610 ////////////////////////////////////////////////////////////////////////////////
611 /// Return the tab element of tab with index tabIndex.
612 /// Returns 0 in case tabIndex is out of range.
613 
615 {
616  if (tabIndex < 0) return 0;
617 
618  TGFrameElement *el;
619  Int_t count = 0;
620 
621  TIter next(fList);
622  next(); // skip first container
623 
624  while ((el = (TGFrameElement *) next())) {
625  next();
626  if (count == tabIndex)
627  return (TGTabElement *) el->fFrame;
628  count++;
629  }
630 
631  return 0;
632 }
633 
634 ////////////////////////////////////////////////////////////////////////////////
635 /// Return the tab element of tab with string name.
636 /// Returns 0 in case name is not found.
637 
638 TGTabElement *TGTab::GetTabTab(const char *name) const
639 {
640  TGFrameElement *el;
641  TGTabElement *tab = 0;
642 
643  TIter next(fList);
644  next();
645 
646  while ((el = (TGFrameElement *) next())) {
647  tab = (TGTabElement *)el->fFrame;
648  if (name == *(tab->GetText())) {
649  return tab;
650  }
651  next();
652  }
653 
654  return 0;
655 }
656 
657 ////////////////////////////////////////////////////////////////////////////////
658 /// Return number of tabs.
659 
661 {
662  Int_t count = 0;
663 
664  TIter next(fList);
665  next(); // skip first container
666 
667  while (next()) {
668  next();
669  count++;
670  }
671 
672  return count;
673 }
674 
675 ////////////////////////////////////////////////////////////////////////////////
676 /// Return default font structure in use.
677 
679 {
680  if (!fgDefaultFont)
681  fgDefaultFont = gClient->GetResourcePool()->GetDefaultFont();
682  return fgDefaultFont->GetFontStruct();
683 }
684 
685 ////////////////////////////////////////////////////////////////////////////////
686 /// Return default graphics context in use.
687 
689 {
690  if (!fgDefaultGC)
691  fgDefaultGC = gClient->GetResourcePool()->GetFrameGC();
692  return *fgDefaultGC;
693 }
694 
695 ////////////////////////////////////////////////////////////////////////////////
696 /// Create new tab. Used in context menu.
697 
698 void TGTab::NewTab(const char *text)
699 {
700  TString name;
701  if (text)
702  name = text;
703  else
704  name = TString::Format("tab%d", GetNumberOfTabs()+1);
705  AddTab(name.Data());
706 
708 }
709 
710 ////////////////////////////////////////////////////////////////////////////////
711 /// Set text to current tab.
712 
713 void TGTab::SetText(const char *text)
714 {
717 }
718 
719 ////////////////////////////////////////////////////////////////////////////////
720 /// Return layout manager.
721 
723 {
724  TGTab *tab = (TGTab*)this;
725 
726  if (tab->fLayoutManager->IsA() != TGTabLayout::Class()) {
727  tab->SetLayoutManager(new TGTabLayout(tab));
728  }
729 
730  return tab->fLayoutManager;
731 }
732 
733 ////////////////////////////////////////////////////////////////////////////////
734 /// Save a tab widget as a C++ statement(s) on output stream out.
735 
736 void TGTab::SavePrimitive(std::ostream &out, Option_t *option /*= ""*/)
737 {
738  char quote = '"';
739 
740  // font + GC
741  option = GetName()+5; // unique digit id of the name
742  TString parGC, parFont;
743  parFont.Form("%s::GetDefaultFontStruct()",IsA()->GetName());
744  parGC.Form("%s::GetDefaultGC()()",IsA()->GetName());
745 
746  if ((GetDefaultFontStruct() != fFontStruct) || (GetDefaultGC()() != fNormGC)) {
747  TGFont *ufont = gClient->GetResourcePool()->GetFontPool()->FindFont(fFontStruct);
748  if (ufont) {
749  ufont->SavePrimitive(out, option);
750  parFont.Form("ufont->GetFontStruct()");
751  }
752 
753  TGGC *userGC = gClient->GetResourcePool()->GetGCPool()->FindGC(fNormGC);
754  if (userGC) {
755  userGC->SavePrimitive(out, option);
756  parGC.Form("uGC->GetGC()");
757  }
758  }
759 
760  if (fBackground != GetDefaultFrameBackground()) SaveUserColor(out, option);
761 
762  out << std::endl << " // tab widget" << std::endl;
763 
764  out << " TGTab *";
765  out << GetName() << " = new TGTab(" << fParent->GetName()
766  << "," << GetWidth() << "," << GetHeight();
767 
769  if (GetOptions() == kChildFrame) {
771  if (fNormGC == GetDefaultGC()()) {
772  out <<");" << std::endl;
773  } else {
774  out << "," << parGC.Data() <<");" << std::endl;
775  }
776  } else {
777  out << "," << parGC.Data() << "," << parFont.Data() <<");" << std::endl;
778  }
779  } else {
780  out << "," << parGC.Data() << "," << parFont.Data() << "," << GetOptionString() <<");" << std::endl;
781  }
782  } else {
783  out << "," << parGC.Data() << "," << parFont.Data() << "," << GetOptionString() << ",ucolor);" << std::endl;
784  }
785  if (option && strstr(option, "keep_names"))
786  out << " " << GetName() << "->SetName(\"" << GetName() << "\");" << std::endl;
787 
788  TGCompositeFrame *cf;
789  TGLayoutManager * lm;
790  for (Int_t i=0; i<GetNumberOfTabs(); i++) {
791  cf = GetTabContainer(i);
792  if (!cf || !GetTabTab(i)) continue;
793  out << std::endl << " // container of " << quote
794  << GetTabTab(i)->GetString() << quote << std::endl;
795  out << " TGCompositeFrame *" << cf->GetName() << ";" << std::endl;
796  out << " " << cf->GetName() << " = " << GetName()
797  << "->AddTab(" << quote << GetTabTab(i)->GetString()
798  << quote << ");" << std::endl;
799  lm = cf->GetLayoutManager();
800  if (lm) {
801  if ((cf->GetOptions() & kHorizontalFrame) &&
803  ;
804  } else if ((GetOptions() & kVerticalFrame) &&
806  ;
807  } else {
808  out << " " << cf->GetName() <<"->SetLayoutManager(";
809  lm->SavePrimitive(out, option);
810  out << ");" << std::endl;
811  }
812  if (!IsEnabled(i)) {
813  out << " " << GetName() << "->SetEnabled(" << i << ", kFALSE);" << std::endl;
814  }
815  }
816  cf->SavePrimitiveSubframes(out, option);
817 
818  if (GetTabTab(i)->IsCloseShown()) {
819  out << " TGTabElement *tab" << i << " = "
820  << GetName() << "->GetTabTab(" << i << ");" << std::endl;
821  out << " tab" << i << "->ShowClose(kTRUE);" << std::endl;
822  }
824  GetTabTab(i)->SaveUserColor(out, option);
825  out << " TGTabElement *tab" << i << " = "
826  << GetName() << "->GetTabTab(" << i << ");" << std::endl;
827  out << " tab" << i << "->ChangeBackground(ucolor);" << std::endl;
828  }
829 
830  }
831  out << std::endl << " " << GetName() << "->SetTab(" << GetCurrent() << ");" << std::endl;
832  out << std::endl << " " << GetName() << "->Resize(" << GetName()
833  << "->GetDefaultSize());" << std::endl;
834 }
835 
836 // __________________________________________________________________________
837 void TGTabLayout::SavePrimitive(std::ostream &out, Option_t * /*= ""*/)
838 {
839  // Save tab layout manager as a C++ statement(s) on out stream.
840 
841  out << "new TGTabLayout(" << fMain->GetName() << ")";
842 
843 }
TGTab::GetCurrentTab
TGTabElement * GetCurrentTab() const
Definition: TGTab.h:111
c
#define c(i)
Definition: RSha256.hxx:119
Event_t::fType
EGEventType fType
Definition: GuiTypes.h:174
TGTab::GetCurrent
Int_t GetCurrent() const
Definition: TGTab.h:105
TGFrame::GetHeight
UInt_t GetHeight() const
Definition: TGFrame.h:250
TGTab::fgDefaultGC
static const TGGC * fgDefaultGC
Definition: TGTab.h:75
TObject::SavePrimitive
virtual void SavePrimitive(std::ostream &out, Option_t *option="")
Save a primitive as a C++ statement(s) on output stream "out".
Definition: TObject.cxx:666
Event_t::fY
Int_t fY
Definition: GuiTypes.h:177
Event_t::fX
Int_t fX
Definition: GuiTypes.h:177
TGWindow
Definition: TGWindow.h:31
TGTabElement::fNormGC
GContext_t fNormGC
Definition: TGTab.h:136
kTRUE
const Bool_t kTRUE
Definition: RtypesCore.h:91
TGTab::~TGTab
virtual ~TGTab()
Delete tab widget.
Definition: TGTab.cxx:332
TGCompositeFrame::GetList
virtual TList * GetList() const
Definition: TGFrame.h:347
TGCompositeFrame::GetLayoutManager
virtual TGLayoutManager * GetLayoutManager() const
Definition: TGFrame.h:375
TGTabElement::~TGTabElement
virtual ~TGTabElement()
Delete tab element.
Definition: TGTab.cxx:90
kAnyModifier
const Mask_t kAnyModifier
Definition: GuiTypes.h:209
TGDimension
Definition: TGDimension.h:27
TGClient::ProcessLine
void ProcessLine(TString cmd, Long_t msg, Long_t parm1, Long_t parm2)
Execute string "cmd" via the interpreter.
Definition: TGClient.cxx:914
TMath::Max
Short_t Max(Short_t a, Short_t b)
Definition: TMathBase.h:212
TGTabElement::fClosePic
const TGPicture * fClosePic
Definition: TGTab.h:134
TGTabElement::HandleButton
virtual Bool_t HandleButton(Event_t *event)
Handle button event in the tab widget.
Definition: TGTab.cxx:134
TGWindow::RaiseWindow
virtual void RaiseWindow()
raise window
Definition: TGWindow.cxx:189
gVirtualX
#define gVirtualX
Definition: TVirtualX.h:338
TGTabElement::SetEnabled
virtual void SetEnabled(Bool_t on=kTRUE)
Definition: TGTab.h:162
TGTab::GetTabContainer
TGCompositeFrame * GetTabContainer(Int_t tabIndex) const
Return container of tab with index tabIndex.
Definition: TGTab.cxx:565
TGCompositeFrame::TGCompositeFrame
TGCompositeFrame(const TGCompositeFrame &)
TList::Delete
virtual void Delete(Option_t *option="")
Remove all objects from the list AND delete all heap based objects.
Definition: TList.cxx:469
TString::Data
const char * Data() const
Definition: TString.h:369
TGTab::SetEnabled
virtual void SetEnabled(Int_t tabIndex, Bool_t on=kTRUE)
Enable or disable tab.
Definition: TGTab.cxx:437
ClassImp
#define ClassImp(name)
Definition: Rtypes.h:364
TGPicture.h
TGFrame::fWidth
UInt_t fWidth
Definition: TGFrame.h:112
TGGC::SavePrimitive
void SavePrimitive(std::ostream &out, Option_t *option="")
Save graphics context info as a C++ statement(s) on output stream out.
Definition: TGGC.cxx:626
kVerticalFrame
@ kVerticalFrame
Definition: GuiTypes.h:381
FontStruct_t
Handle_t FontStruct_t
Definition: GuiTypes.h:38
TGTab::NewTab
virtual void NewTab(const char *text="tab")
Create new tab. Used in context menu.
Definition: TGTab.cxx:698
TGWindow::kEditDisableLayout
@ kEditDisableLayout
Definition: TGWindow.h:61
TGCompositeFrame::Cleanup
virtual void Cleanup()
Cleanup and delete all objects contained in this composite frame.
Definition: TGFrame.cxx:952
TGTab::fgDefaultFont
static const TGFont * fgDefaultFont
Definition: TGTab.h:74
TGTabElement::GetDefaultSize
virtual TGDimension GetDefaultSize() const
Return default size of tab element.
Definition: TGTab.cxx:171
TGWindow::kEditDisable
@ kEditDisable
Definition: TGWindow.h:58
TGTabElement::fText
TGString * fText
Definition: TGTab.h:133
TGTabElement::fActive
Bool_t fActive
Definition: TGTab.h:142
TGTab::GetDefaultGC
static const TGGC & GetDefaultGC()
Return default graphics context in use.
Definition: TGTab.cxx:688
Int_t
int Int_t
Definition: RtypesCore.h:45
TGCompositeFrame::SetEditDisabled
virtual void SetEditDisabled(UInt_t on=1)
Set edit disable flag for this frame and subframes.
Definition: TGFrame.cxx:1007
TGPicture::Draw
void Draw(Option_t *="")
Default Draw method for all objects.
Definition: TGPicture.h:57
TGTabElement::GetText
const TGString * GetText() const
Definition: TGTab.h:158
TClass.h
TList.h
kButton1
@ kButton1
Definition: GuiTypes.h:213
TGTab::GetContainer
TGCompositeFrame * GetContainer() const
Definition: TGTab.h:104
TGFrame::GetDefaultFrameBackground
static Pixel_t GetDefaultFrameBackground()
Get default frame background.
Definition: TGFrame.cxx:668
TVirtualX.h
TGTabLayout::TGTabLayout
TGTabLayout(const TGTabLayout &)
TGFrame::GetBackground
virtual Pixel_t GetBackground() const
Definition: TGFrame.h:217
TString::Format
static TString Format(const char *fmt,...)
Static method which formats a string using a printf style format descriptor and return a TString.
Definition: TString.cxx:2311
TGFrame::GetDefaultSize
virtual TGDimension GetDefaultSize() const
std::cout << fWidth << "x" << fHeight << std::endl;
Definition: TGFrame.cxx:569
TGTab::fCurrent
Int_t fCurrent
Definition: TGTab.h:65
TGFrame::GetBlackGC
static const TGGC & GetBlackGC()
Get black graphics context.
Definition: TGFrame.cxx:720
TString
Definition: TString.h:136
TGFrame
Definition: TGFrame.h:105
kButtonPressMask
const Mask_t kButtonPressMask
Definition: GuiTypes.h:160
TGObject::GetId
Handle_t GetId() const
Definition: TGObject.h:47
TGTabElement::DrawBorder
virtual void DrawBorder()
Draw little tab element.
Definition: TGTab.cxx:100
TGTab::TGTab
TGTab(const TGTab &)
kDoubleBorder
@ kDoubleBorder
Definition: GuiTypes.h:385
TGTabElement
Definition: TGTab.h:130
TObject::InheritsFrom
virtual Bool_t InheritsFrom(const char *classname) const
Returns kTRUE if object inherits from class "classname".
Definition: TObject.cxx:445
TGTab::GetDefaultFontStruct
static FontStruct_t GetDefaultFontStruct()
Return default font structure in use.
Definition: TGTab.cxx:678
text
TText * text
Definition: entrylist_figure1.C:10
TGFrame::MapWindow
virtual void MapWindow()
map window
Definition: TGFrame.h:229
bool
TGCompositeFrame::SavePrimitiveSubframes
virtual void SavePrimitiveSubframes(std::ostream &out, Option_t *option="")
Auxilary protected method used to save subframes.
Definition: TGFrame.cxx:2626
TGFrame::GetWidth
UInt_t GetWidth() const
Definition: TGFrame.h:249
TGTab::fFontStruct
FontStruct_t fFontStruct
Definition: TGTab.h:69
TGCompositeFrame::fList
TList * fList
Definition: TGFrame.h:329
TGWindow::kEditDisableBtnEnable
@ kEditDisableBtnEnable
Definition: TGWindow.h:65
TGFrameElement::fFrame
TGFrame * fFrame
Definition: TGLayout.h:119
TGTabLayout::fList
TList * fList
Definition: TGTab.h:44
TGFrame::GetOptionString
TString GetOptionString() const
Returns a frame option string - used in SavePrimitive().
Definition: TGFrame.cxx:2465
TGLayoutManager
Definition: TGLayout.h:142
TGFrame::GetOptions
virtual UInt_t GetOptions() const
Definition: TGFrame.h:222
TGTab::Selected
virtual void Selected(Int_t id)
Definition: TGTab.h:122
TGWindow::DestroyWindow
virtual void DestroyWindow()
destroy window
Definition: TGWindow.cxx:173
GContext_t
Handle_t GContext_t
Definition: GuiTypes.h:37
TGTab::fRemoved
TList * fRemoved
Definition: TGTab.h:68
gClient
#define gClient
Definition: TGClient.h:166
TGTabElement::fTWidth
UInt_t fTWidth
Definition: TGTab.h:138
TGWidget::fCommand
TString fCommand
Definition: TGWidget.h:61
TGTab::fContainer
TGCompositeFrame * fContainer
Definition: TGTab.h:67
TGString::GetLength
Int_t GetLength() const
Definition: TGString.h:45
kNone
const Handle_t kNone
Definition: GuiTypes.h:87
TString::Form
void Form(const char *fmt,...)
Formats a string using a printf style format descriptor.
Definition: TString.cxx:2289
TGFrame::GetHilightGC
static const TGGC & GetHilightGC()
Get highlight color graphics context.
Definition: TGFrame.cxx:740
TGTabElement::SetActive
virtual void SetActive(Bool_t on=kTRUE)
Definition: TGTab.h:167
TGTab::SetText
virtual void SetText(const char *text="tab")
Set text to current tab.
Definition: TGTab.cxx:713
TGTab::GetLayoutManager
virtual TGLayoutManager * GetLayoutManager() const
Return layout manager.
Definition: TGTab.cxx:722
Option_t
const typedef char Option_t
Definition: RtypesCore.h:66
TGTabElement::fTHeight
UInt_t fTHeight
Definition: TGTab.h:139
TGWindow::kEditDisableGrab
@ kEditDisableGrab
Definition: TGWindow.h:60
TGDimension::fHeight
UInt_t fHeight
Definition: TGDimension.h:36
h
#define h(i)
Definition: RSha256.hxx:124
TGWidget::fMsgWindow
const TGWindow * fMsgWindow
Definition: TGWidget.h:60
TGWindow::GetName
virtual const char * GetName() const
Return unique name, used in SavePrimitive methods.
Definition: TGWindow.cxx:317
TGGC
Definition: TGGC.h:31
TGTab::AddTab
virtual TGCompositeFrame * AddTab(TGString *text)
Add a tab to the tab widget.
Definition: TGTab.cxx:343
TGFrame::Resize
virtual void Resize(UInt_t w=0, UInt_t h=0)
Resize the frame.
Definition: TGFrame.cxx:590
TGObject::fId
Handle_t fId
Definition: TGObject.h:36
TGTabElement::fShowClose
Bool_t fShowClose
Definition: TGTab.h:141
TGFrame::SendMessage
virtual void SendMessage(const TGWindow *w, Long_t msg, Long_t parm1, Long_t parm2)
Send message (i.e.
Definition: TGFrame.cxx:630
kFALSE
const Bool_t kFALSE
Definition: RtypesCore.h:92
TGLayoutManager::Layout
virtual void Layout()=0
TGTabElement::GetString
const char * GetString() const
Definition: TGTab.h:159
TGFrame::fBorderWidth
Int_t fBorderWidth
Definition: TGFrame.h:118
kButtonPress
@ kButtonPress
Definition: GuiTypes.h:59
main
int main(int argc, char **argv)
Definition: histspeedtest.cxx:752
TGWidget::IsEnabled
Bool_t IsEnabled() const
Definition: TGWidget.h:81
TGDimension::fWidth
UInt_t fWidth
Definition: TGDimension.h:35
TGFrame::SaveUserColor
void SaveUserColor(std::ostream &out, Option_t *)
Save a user color in a C++ macro file - used in SavePrimitive().
Definition: TGFrame.cxx:2438
TGTab
Definition: TGTab.h:62
TGClient::GetPicture
const TGPicture * GetPicture(const char *name)
Get picture from the picture pool.
Definition: TGClient.cxx:290
Window_t
Handle_t Window_t
Definition: GuiTypes.h:28
UInt_t
unsigned int UInt_t
Definition: RtypesCore.h:46
TGTab.h
ULong_t
unsigned long ULong_t
Definition: RtypesCore.h:55
TGTab::SetTab
virtual Bool_t SetTab(Int_t tabIndex, Bool_t emit=kTRUE)
Brings the composite frame with the index tabIndex to the front and generate the following event if t...
Definition: TGTab.cxx:509
TGTab::ChangeTab
void ChangeTab(Int_t tabIndex, Bool_t emit=kTRUE)
Make tabIdx the current tab.
Definition: TGTab.cxx:460
TGCompositeFrame::RemoveFrame
virtual void RemoveFrame(TGFrame *f)
Remove frame from composite frame.
Definition: TGFrame.cxx:1134
TGCompositeFrame::SetLayoutManager
virtual void SetLayoutManager(TGLayoutManager *l)
Set the layout manager for the composite frame.
Definition: TGFrame.cxx:985
Event_t::fWindow
Window_t fWindow
Definition: GuiTypes.h:175
kRaisedFrame
@ kRaisedFrame
Definition: GuiTypes.h:384
TGTabElement::IsEnabled
Bool_t IsEnabled() const
Definition: TGTab.h:163
unsigned int
TGTabLayout::Layout
virtual void Layout()
Layout the tab widget.
Definition: TGTab.cxx:223
kHorizontalFrame
@ kHorizontalFrame
Definition: GuiTypes.h:382
TGTabLayout::fMain
TGTab * fMain
Definition: TGTab.h:43
TGTabElement::fFontStruct
FontStruct_t fFontStruct
Definition: TGTab.h:137
TGWindow::LowerWindow
virtual void LowerWindow()
lower window
Definition: TGWindow.cxx:197
TGClient::NeedRedraw
void NeedRedraw(TGWindow *w, Bool_t force=kFALSE)
Set redraw flags.
Definition: TGClient.cxx:373
TGTabLayout::GetDefaultSize
virtual TGDimension GetDefaultSize() const
Get default size of tab widget.
Definition: TGTab.cxx:267
TGTab::SavePrimitive
virtual void SavePrimitive(std::ostream &out, Option_t *option="")
Save a tab widget as a C++ statement(s) on output stream out.
Definition: TGTab.cxx:736
TGFrame::UnmapWindow
virtual void UnmapWindow()
unmap window
Definition: TGFrame.h:231
TGFrame::GetBorderWidth
Int_t GetBorderWidth() const
Definition: TGFrame.h:258
TGObject::fClient
TGClient * fClient
Definition: TGObject.h:37
TGFrame::MoveResize
virtual void MoveResize(Int_t x, Int_t y, UInt_t w=0, UInt_t h=0)
Move and/or resize the frame.
Definition: TGFrame.cxx:614
TGTab::fNormGC
GContext_t fNormGC
Definition: TGTab.h:70
kC_COMMAND
@ kC_COMMAND
Definition: WidgetMessageTypes.h:39
TGCompositeFrame::fLayoutManager
TGLayoutManager * fLayoutManager
Definition: TGFrame.h:328
TList::Add
virtual void Add(TObject *obj)
Definition: TList.h:87
TGTab::RemoveTab
virtual void RemoveTab(Int_t tabIndex=-1, Bool_t storeRemoved=kTRUE)
Remove container and tab of tab with index tabIndex.
Definition: TGTab.cxx:394
TGTabElement::fEnabled
Bool_t fEnabled
Definition: TGTab.h:140
TGTabLayout::SavePrimitive
virtual void SavePrimitive(std::ostream &out, Option_t *option="")
Save a primitive as a C++ statement(s) on output stream "out".
Definition: TGTab.cxx:837
Event_t
Definition: GuiTypes.h:173
name
char name[80]
Definition: TGX11.cxx:110
TGString::Draw
virtual void Draw(Drawable_t id, GContext_t gc, Int_t x, Int_t y)
Draw string.
Definition: TGString.cxx:51
TGTabLayout
Definition: TGTab.h:40
TGFrameElement
Definition: TGLayout.h:112
kCM_TAB
@ kCM_TAB
Definition: WidgetMessageTypes.h:47
TGFrame::GetShadowGC
static const TGGC & GetShadowGC()
Get shadow color graphics context.
Definition: TGFrame.cxx:750
TGString::GetString
const char * GetString() const
Definition: TGString.h:46
TIter
Definition: TCollection.h:233
TGFont::SavePrimitive
virtual void SavePrimitive(std::ostream &out, Option_t *="")
Save the used font as a C++ statement(s) on output stream out.
Definition: TGFont.cxx:1871
TGTabElement::ShowClose
virtual void ShowClose(Bool_t on=kTRUE)
Show/hide close icon on the tab element, then apply layout to compute correct elements size.
Definition: TGTab.cxx:199
TGTabElement::TGTabElement
TGTabElement(const TGTabElement &)
TGResourcePool.h
TGFont::GetFontStruct
FontStruct_t GetFontStruct() const
Definition: TGFont.h:193
TGTab::Removed
virtual void Removed(Int_t id)
Definition: TGTab.h:121
TGFrame::fHeight
UInt_t fHeight
Definition: TGFrame.h:113
TGTab::GetNumberOfTabs
Int_t GetNumberOfTabs() const
Return number of tabs.
Definition: TGTab.cxx:660
TGFrame::fBackground
Pixel_t fBackground
Definition: TGFrame.h:120
TGFont
Definition: TGFont.h:149
TGWindow::fEditDisabled
UInt_t fEditDisabled
Definition: TGWindow.h:40
TGFrame::Layout
virtual void Layout()
Definition: TGFrame.h:224
Class
void Class()
Definition: Class.C:29
TGTab::GetTabTab
TGTabElement * GetTabTab(Int_t tabIndex) const
Return the tab element of tab with index tabIndex.
Definition: TGTab.cxx:614
TGCompositeFrame
Definition: TGFrame.h:324
TGCompositeFrame::AddFrame
virtual void AddFrame(TGFrame *f, TGLayoutHints *l=0)
Add frame to the composite frame using the specified layout hints.
Definition: TGFrame.cxx:1102
TGFrame::GetDefaultWidth
virtual UInt_t GetDefaultWidth() const
Definition: TGFrame.h:215
TGString
Definition: TGString.h:30
TGTabElement::fClosePicD
const TGPicture * fClosePicD
Definition: TGTab.h:135
TGTab::GetTabHeight
UInt_t GetTabHeight() const
Definition: TGTab.h:112
TGTab::fTabh
UInt_t fTabh
Definition: TGTab.h:66
TGWindow::kEditDisableResize
@ kEditDisableResize
Definition: TGWindow.h:62
MK_MSG
Int_t MK_MSG(EWidgetMessageTypes msg, EWidgetMessageTypes submsg)
Definition: WidgetMessageTypes.h:110
TGWindow::fParent
const TGWindow * fParent
Definition: TGWindow.h:36
TGTabElement::SetText
void SetText(TGString *text)
Set new tab text.
Definition: TGTab.cxx:182
TList
Definition: TList.h:44
kChildFrame
@ kChildFrame
Definition: GuiTypes.h:379
int