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