Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
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/** \class TGTab
25 \ingroup guiwidgets
26
27A tab widget contains a set of composite frames each with a little
28tab with a name (like a set of folders with tabs).
29
30Clicking on a tab will bring the associated composite frame to the
31front and generate the following event:
32kC_COMMAND, kCM_TAB, tab id, 0.
33
34\class TGTabElement
35\ingroup guiwidgets
36Service classes of the tab widget.
37
38\class TGTabLayout
39\ingroup guiwidgets
40Service classes of the tab widget.
41
42*/
43
44
45#include "TGTab.h"
46#include "TGResourcePool.h"
47#include "TList.h"
48#include "TClass.h"
49#include "TGPicture.h"
50#include "TVirtualX.h"
51
52#include <iostream>
53
54const TGFont *TGTab::fgDefaultFont = nullptr;
55const TGGC *TGTab::fgDefaultGC = nullptr;
56
60
61
62////////////////////////////////////////////////////////////////////////////////
63/// Create a tab element. Text is adopted by tab element.
64
66 GContext_t norm, FontStruct_t font,
67 UInt_t options, Pixel_t back) :
68 TGFrame(p, w, h, options, back)
69{
70 fClosePic = 0;
71 fClosePicD = 0;
74 fText = text;
75 fBorderWidth = 0;
76 fTWidth = 0;
77 fNormGC = norm;
78 fFontStruct = font;
80
81 fClosePic = fClient->GetPicture("closetab.png");
82 fClosePicD = fClient->GetPicture("closetab_d.png");
83 int max_ascent, max_descent;
84 if (fText)
86 gVirtualX->GetFontProperties(fFontStruct, max_ascent, max_descent);
87 fTHeight = max_ascent + max_descent;
92}
93
94////////////////////////////////////////////////////////////////////////////////
95/// Delete tab element.
96
98{
99 if (fClosePic) gClient->FreePicture(fClosePic);
100 if (fClosePicD) gClient->FreePicture(fClosePicD);
101 if (fText) delete fText;
102}
103
104////////////////////////////////////////////////////////////////////////////////
105/// Draw little tab element.
106
108{
109 gVirtualX->DrawLine(fId, GetHilightGC()(), 0, fHeight-1, 0, 2);
110 gVirtualX->DrawLine(fId, GetHilightGC()(), 0, 2, 2, 0);
111 gVirtualX->DrawLine(fId, GetHilightGC()(), 2, 0, fWidth-3, 0);
112 gVirtualX->DrawLine(fId, GetShadowGC()(), fWidth-2, 1, fWidth-2, fHeight-1);
113 if (gClient->GetStyle() < 2) {
114 gVirtualX->DrawLine(fId, GetBlackGC()(), fWidth-2, 1, fWidth-1, 2);
115 gVirtualX->DrawLine(fId, GetBlackGC()(), fWidth-1, 2, fWidth-1, fHeight-2);
116 }
117 gVirtualX->DrawLine(fId, GetHilightGC()(), fWidth-1, fHeight-1, fWidth-1, fHeight-1);
118
119 if (fText) {
120 int max_ascent, max_descent;
121 gVirtualX->GetFontProperties(fFontStruct, max_ascent, max_descent);
122 if (fEnabled) {
123 fText->Draw(fId, fNormGC, 6, max_ascent+3);
124 } else {
125 fText->Draw(fId, GetHilightGC()(), 7, max_ascent + 1);
126 fText->Draw(fId, GetShadowGC()(), 6, max_ascent);
127 }
128 }
129 if (fShowClose && fClosePic && fClosePicD) {
130 if (fEnabled && fActive)
132 else
134 }
135}
136
137////////////////////////////////////////////////////////////////////////////////
138/// Handle button event in the tab widget. Basically we only handle
139/// button and scroll events in the small tabs.
140
142{
143 if (event->fCode == kButton4 || event->fCode == kButton5) { //scroll wheel events
144 if (fParent) {
145 TGTab* main = (TGTab*)fParent;
146 if (main->IsScrollingEnabled())
147 {
148 if (event->fCode == kButton4) { //scroll up = move left, as in Firefox
149 for (Int_t c = main->GetCurrent() - 1; c >= 0; --c) {
150 if (main->GetTabTab(c)->IsEnabled()) {
151 // change tab and generate event
152 main->SetTab(c);
153 break;
154 }
155 }
156 } else if (event->fCode == kButton5) { //scroll down = move right, as in Firefox
157 for (Int_t c = main->GetCurrent() + 1; c < main->GetNumberOfTabs(); ++c) {
158 if (main->GetTabTab(c)->IsEnabled()) {
159 // change tab and generate event
160 main->SetTab(c);
161 break;
162 }
163 }
164 }
165 }
166 }
167 } else if (event->fType == kButtonPress) { //normal button press events
168 TGTab* main = (TGTab*)fParent;
169 if (main) {
170 if (fShowClose && event->fWindow == GetId() &&
171 (UInt_t)event->fX > fTWidth+12 && (UInt_t)event->fX < fTWidth+26 &&
172 (UInt_t)event->fY > fHeight/2-7 && (UInt_t)event->fY < fHeight/2+7) {
173 if (main->GetTabTab(main->GetCurrent()) == this) {
174 main->CloseTab(main->GetCurrent()); // emit signal
175 //main->RemoveTab(main->GetCurrent());
176 return kTRUE;
177 }
178 }
179 TGFrameElement *el;
180 TIter next(main->GetList());
181
182 next(); // skip first container
183
184 Int_t i = 0;
185 Int_t c = main->GetCurrent();
186 while ((el = (TGFrameElement *) next())) {
187 if (el->fFrame->GetId() == (Window_t)event->fWindow)
188 c = i;
189 next(); i++;
190 }
191
192 // change tab and generate event
193 main->SetTab(c);
194 }
195 }
196 return kTRUE;
197}
198
199////////////////////////////////////////////////////////////////////////////////
200/// Return default size of tab element.
201
203{
205 return TGDimension(TMath::Max(fTWidth+30, (UInt_t)45), fTHeight+6);
206 else
207 return TGDimension(TMath::Max(fTWidth+12, (UInt_t)45), fTHeight+6);
208}
209
210////////////////////////////////////////////////////////////////////////////////
211/// Set new tab text.
212
214{
215 if (fText) delete fText;
216 fText = text;
217
218 int max_ascent, max_descent;
220 gVirtualX->GetFontProperties(fFontStruct, max_ascent, max_descent);
221 fTHeight = max_ascent + max_descent;
222
223 fClient->NeedRedraw(this);
224}
225
226////////////////////////////////////////////////////////////////////////////////
227/// Show/hide close icon on the tab element, then apply layout
228/// to compute correct elements size.
229
231{
232 TGTab* main = (TGTab*)fParent;
233 fShowClose = show;
236 else
238 if (main)
239 main->GetLayoutManager()->Layout();
240}
241
242////////////////////////////////////////////////////////////////////////////////
243/// Create a tab layout manager.
244
246{
247 fMain = main;
248 fList = fMain->GetList();
249}
250
251////////////////////////////////////////////////////////////////////////////////
252/// Layout the tab widget.
253
255{
256 Int_t i, xtab;
257 UInt_t tw;
258 UInt_t tabh = fMain->GetTabHeight(), bw = fMain->GetBorderWidth();
259 UInt_t w = fMain->GetWidth();
260 UInt_t h = fMain->GetHeight();
261
262 xtab = 2;
263
264 fMain->GetContainer()->MoveResize(0, tabh, w, h - tabh);
265
266 // first frame is the container, so take next...
267 TGFrameElement *el, *elnxt;
268 TIter next(fList);
269 i = 0;
270 next(); // skip first
271 while ((el = (TGFrameElement *) next())) {
272 elnxt = (TGFrameElement *) next();
273 tw = el->fFrame->GetDefaultWidth();
274 if (i == fMain->GetCurrent()) {
275 el->fFrame->MoveResize(xtab-2, 0, tw+3, tabh+1);
276 if (elnxt) elnxt->fFrame->RaiseWindow();
277 el->fFrame->RaiseWindow();
278 } else {
279 el->fFrame->MoveResize(xtab, 2, tw, tabh-1);
280 el->fFrame->LowerWindow();
281 }
282 UInt_t nw = (w - (bw << 1));
283 if (nw > 32768) nw = 1;
284 UInt_t nh = (h - tabh - (bw << 1));
285 if (nh > 32768) nh = 1;
286 if (elnxt) {
287 elnxt->fFrame->MoveResize(bw, tabh + bw, nw, nh);
288 elnxt->fFrame->Layout();
289 }
290 xtab += (Int_t)tw;
291 i++;
292 }
293}
294
295////////////////////////////////////////////////////////////////////////////////
296/// Get default size of tab widget.
297
299{
300 TGDimension dsize, dsize_te;
301 TGDimension size(0,0), size_te(0,0);
302
303 TGFrameElement *el, *elnxt;
304 TIter next(fList);
305 next(); // skip first container
306 while ((el = (TGFrameElement *)next())) {
307 dsize_te = el->fFrame->GetDefaultSize();
308 size_te.fWidth += dsize_te.fWidth;
309 elnxt = (TGFrameElement *) next();
310 if (elnxt) {
311 dsize = elnxt->fFrame->GetDefaultSize();
312 if (size.fWidth < dsize.fWidth) size.fWidth = dsize.fWidth;
313 if (size.fHeight < dsize.fHeight) size.fHeight = dsize.fHeight;
314 }
315 }
316
317 // check if tab elements make a larger width than the containers
318 if (size.fWidth < size_te.fWidth) size.fWidth = size_te.fWidth;
319
320 size.fWidth += fMain->GetBorderWidth() << 1;
321 size.fHeight += fMain->GetTabHeight() + (fMain->GetBorderWidth() << 1);
322
323 return size;
324}
325
326
327////////////////////////////////////////////////////////////////////////////////
328/// Create tab widget.
329
331 GContext_t norm, FontStruct_t font,
332 UInt_t options, Pixel_t back) :
333 TGCompositeFrame(p, w, h, options, back)
334{
335 fMsgWindow = p;
336
337 fBorderWidth = 2;
338 fCurrent = 0;
339 fRemoved = new TList;
340
341 fNormGC = norm;
342 fFontStruct = font;
343
345
346 int max_ascent, max_descent;
347 gVirtualX->GetFontProperties(fFontStruct, max_ascent, max_descent);
348 fTabh = max_ascent + max_descent + 6;
349
350 SetLayoutManager(new TGTabLayout(this));
351
352 // we need this in order to avoid border blinking when switching tabs...
356
359}
360
361////////////////////////////////////////////////////////////////////////////////
362/// Delete tab widget. This deletes the tab windows and the containers.
363/// The tab string is deleted by the TGTabElement dtor.
364
366{
367 Cleanup();
368 fRemoved->Delete();
369 delete fRemoved;
370}
371
372////////////////////////////////////////////////////////////////////////////////
373/// Add a tab to the tab widget. Returns the new container, which
374/// is owned by the tab widget. The text is adopted by the tab widget.
375
377{
378 TGTabElement *te = new TGTabElement(this, text, 50, 20, fNormGC, fFontStruct);
379 AddFrame(te, 0);
380
381 TGCompositeFrame* cf = new TGCompositeFrame(this, fWidth, fHeight-21);
382 AddFrame(cf, 0);
384
385 te->MapWindow();
386 cf->MapWindow();
387
388 return cf;
389}
390
391////////////////////////////////////////////////////////////////////////////////
392/// Add a tab to the tab widget. Returns the new container. The container
393/// is owned by the tab widget.
394
396{
397 return AddTab(new TGString(text));
398}
399
400////////////////////////////////////////////////////////////////////////////////
401/// Add a tab to the tab widget and fill it with given TGCompositeFrame.
402
403void TGTab::AddTab(const char *text, TGCompositeFrame *cf)
404{
405 AddTab(new TGString(text), cf);
406}
407
408////////////////////////////////////////////////////////////////////////////////
409/// Add a tab to the tab widget and fill it with given TGCompositeFrame.
410
412{
413 TGTabElement *te = new TGTabElement(this, text, 50, 20, fNormGC, fFontStruct);
414 AddFrame(te, 0);
415
416 AddFrame(cf, 0);
418
419 te->MapWindow();
420 cf->MapWindow();
421}
422
423////////////////////////////////////////////////////////////////////////////////
424/// Remove container and tab of tab with index tabIndex.
425/// Does NOT remove the container contents!
426
427void TGTab::RemoveTab(Int_t tabIndex, Bool_t storeRemoved)
428{
429 if (tabIndex < 0) {
430 tabIndex = fCurrent;
431 }
432
433 TGFrameElement *elTab, *elCont;
434 Int_t count = 0;
435
436 // Notify (signal) for removed tab "tabIndex"
437 Removed(tabIndex);
438
439 TIter next(fList) ;
440 next() ; // skip first container
441
442 while ((elTab = (TGFrameElement *) next())) {
443 elCont = (TGFrameElement *) next();
444
445 if (count == tabIndex) {
446 elCont->fFrame->UnmapWindow(); // will be destroyed later
447 TGFrame *frame = elTab->fFrame;
448 RemoveFrame(elTab->fFrame);
449 frame->DestroyWindow();
450 delete frame;
451 if (storeRemoved)
452 fRemoved->Add(elCont->fFrame); // delete only in dtor
453 RemoveFrame(elCont->fFrame);
454 if (tabIndex == fCurrent) {
455 // select another tab only if the current is the one we delete
456 SetTab(0);
457 } else
458 fCurrent--;
459 break;
460 }
461 count++;
462 }
463
465}
466
467////////////////////////////////////////////////////////////////////////////////
468/// Enable or disable tab.
469
471{
472 TGTabElement *te = GetTabTab(tabIndex);
473 if (te) {
474 te->SetEnabled(on);
475 fClient->NeedRedraw(te);
476 }
477}
478
479////////////////////////////////////////////////////////////////////////////////
480/// Returns true if tab scrolling is enabled.
481
483{
484 return fScrolling;
485}
486
487////////////////////////////////////////////////////////////////////////////////
488/// Enable or disable tab scrolling.
489
491{
492 fScrolling = on;
493}
494
495////////////////////////////////////////////////////////////////////////////////
496/// Returns true if tab is enabled.
497
499{
500 TGTabElement *te = GetTabTab(tabIndex);
501
502 return te ? te->IsEnabled() : kFALSE;
503}
504
505////////////////////////////////////////////////////////////////////////////////
506/// Make tabIdx the current tab. Utility method called by SetTab and
507/// HandleButton().
508
509void TGTab::ChangeTab(Int_t tabIndex, Bool_t emit)
510{
511 TGTabElement *te = GetTabTab(tabIndex);
512 if (!te || !te->IsEnabled()) return;
513
514 if (tabIndex != fCurrent) {
515 if (GetTabTab(fCurrent)) {
518 }
519 TGFrameElement *el, *elnxt;
520 UInt_t tw;
521 Int_t xtab = 2;
522 Int_t count = 0;
523
524 TIter next(fList);
525 next(); // skip first container
526
527 fCurrent = tabIndex;
528 while ((el = (TGFrameElement *) next())) {
529 elnxt = (TGFrameElement *) next();
530 tw = el->fFrame->GetDefaultWidth();
531 if (count == fCurrent) {
532 el->fFrame->MoveResize(xtab-2, 0, tw+3, fTabh+1);
533 if (elnxt) elnxt->fFrame->RaiseWindow();
534 el->fFrame->RaiseWindow();
535 } else {
536 el->fFrame->MoveResize(xtab, 2, tw, fTabh-1);
537 el->fFrame->LowerWindow();
538 }
539 xtab += tw;
540 count++;
541 }
542 if (emit) {
546 }
549 }
550}
551
552////////////////////////////////////////////////////////////////////////////////
553/// Brings the composite frame with the index tabIndex to the
554/// front and generate the following event if the front tab has changed:
555/// kC_COMMAND, kCM_TAB, tab id, 0.
556/// Returns kFALSE if tabIndex is a not valid index
557
559{
560 // check if tabIndex is a valid index
561 if (tabIndex < 0)
562 return kFALSE;
563
564 // count the tabs
565 TIter next(fList);
566 Int_t count = 0;
567 while (next())
568 count++;
569
570 count = count / 2 - 1;
571 if (tabIndex > count)
572 return kFALSE;
573
574 // change tab and generate event
575 ChangeTab(tabIndex, emit);
576
577 return kTRUE;
578}
579
580////////////////////////////////////////////////////////////////////////////////
581/// Brings the composite frame with the name to the
582/// front and generate the following event if the front tab has changed:
583/// kC_COMMAND, kCM_TAB, tab id, 0.
584/// Returns kFALSE if tab with name does not exist.
585
586Bool_t TGTab::SetTab(const char *name, Bool_t emit)
587{
588 TGFrameElement *el;
589 Int_t count = 0;
590 TGTabElement *tab = 0;
591
592 TIter next(fList);
593 next(); // skip first container
594
595 while ((el = (TGFrameElement *) next())) {
596 next(); // skip tab container
597 tab = (TGTabElement *)el->fFrame;
598
599 if (*(tab->GetText()) == name) {
600 // change tab and generate event
601 ChangeTab(count, emit);
602 return kTRUE;
603 }
604 count++;
605 }
606
607 return kFALSE;
608}
609
610////////////////////////////////////////////////////////////////////////////////
611/// Return container of tab with index tabIndex.
612/// Return 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 (next()) {
625 el = (TGFrameElement *) next();
626 if (el && count == tabIndex)
627 return (TGCompositeFrame *) el->fFrame;
628 count++;
629 }
630
631 return 0;
632}
633
634////////////////////////////////////////////////////////////////////////////////
635/// Return the tab container of tab with string name.
636/// Returns 0 in case name is not found.
637
639{
640 TGFrameElement *el;
641 TGTabElement *tab = 0;
642 TGCompositeFrame *comp = 0;
643
644 TIter next(fList);
645 next();
646
647 while ((el = (TGFrameElement *) next())) {
648 tab = (TGTabElement *) el->fFrame;
649 el = (TGFrameElement *) next();
650 comp = (TGCompositeFrame *) el->fFrame;
651 if (*tab->GetText() == name){
652 return comp;
653 }
654 }
655
656 return 0;
657}
658
659////////////////////////////////////////////////////////////////////////////////
660/// Return the tab element of tab with index tabIndex.
661/// Returns 0 in case tabIndex is out of range.
662
664{
665 if (tabIndex < 0) return 0;
666
667 TGFrameElement *el;
668 Int_t count = 0;
669
670 TIter next(fList);
671 next(); // skip first container
672
673 while ((el = (TGFrameElement *) next())) {
674 next();
675 if (count == tabIndex)
676 return (TGTabElement *) el->fFrame;
677 count++;
678 }
679
680 return 0;
681}
682
683////////////////////////////////////////////////////////////////////////////////
684/// Return the tab element of tab with string name.
685/// Returns 0 in case name is not found.
686
688{
689 TGFrameElement *el;
690 TGTabElement *tab = 0;
691
692 TIter next(fList);
693 next();
694
695 while ((el = (TGFrameElement *) next())) {
696 tab = (TGTabElement *)el->fFrame;
697 if (name == *(tab->GetText())) {
698 return tab;
699 }
700 next();
701 }
702
703 return 0;
704}
705
706////////////////////////////////////////////////////////////////////////////////
707/// Return number of tabs.
708
710{
711 Int_t count = 0;
712
713 TIter next(fList);
714 next(); // skip first container
715
716 while (next()) {
717 next();
718 count++;
719 }
720
721 return count;
722}
723
724////////////////////////////////////////////////////////////////////////////////
725/// Return default font structure in use.
726
728{
729 if (!fgDefaultFont)
730 fgDefaultFont = gClient->GetResourcePool()->GetDefaultFont();
732}
733
734////////////////////////////////////////////////////////////////////////////////
735/// Return default graphics context in use.
736
738{
739 if (!fgDefaultGC)
740 fgDefaultGC = gClient->GetResourcePool()->GetFrameGC();
741 return *fgDefaultGC;
742}
743
744////////////////////////////////////////////////////////////////////////////////
745/// Create new tab. Used in context menu.
746
747void TGTab::NewTab(const char *text)
748{
750 if (text)
751 name = text;
752 else
753 name = TString::Format("tab%d", GetNumberOfTabs()+1);
754 AddTab(name.Data());
755
757}
758
759////////////////////////////////////////////////////////////////////////////////
760/// Set text to current tab.
761
762void TGTab::SetText(const char *text)
763{
766}
767
768////////////////////////////////////////////////////////////////////////////////
769/// Return layout manager.
770
772{
773 TGTab *tab = (TGTab*)this;
774
775 if (tab->fLayoutManager->IsA() != TGTabLayout::Class()) {
776 tab->SetLayoutManager(new TGTabLayout(tab));
777 }
778
779 return tab->fLayoutManager;
780}
781
782////////////////////////////////////////////////////////////////////////////////
783/// Save a tab widget as a C++ statement(s) on output stream out.
784
785void TGTab::SavePrimitive(std::ostream &out, Option_t *option /*= ""*/)
786{
787 char quote = '"';
788
789 // font + GC
790 option = GetName()+5; // unique digit id of the name
791 TString parGC, parFont;
792 parFont.Form("%s::GetDefaultFontStruct()",IsA()->GetName());
793 parGC.Form("%s::GetDefaultGC()()",IsA()->GetName());
794
795 if ((GetDefaultFontStruct() != fFontStruct) || (GetDefaultGC()() != fNormGC)) {
796 TGFont *ufont = gClient->GetResourcePool()->GetFontPool()->FindFont(fFontStruct);
797 if (ufont) {
798 ufont->SavePrimitive(out, option);
799 parFont.Form("ufont->GetFontStruct()");
800 }
801
802 TGGC *userGC = gClient->GetResourcePool()->GetGCPool()->FindGC(fNormGC);
803 if (userGC) {
804 userGC->SavePrimitive(out, option);
805 parGC.Form("uGC->GetGC()");
806 }
807 }
808
810
811 out << std::endl << " // tab widget" << std::endl;
812
813 out << " TGTab *";
814 out << GetName() << " = new TGTab(" << fParent->GetName()
815 << "," << GetWidth() << "," << GetHeight();
816
818 if (GetOptions() == kChildFrame) {
820 if (fNormGC == GetDefaultGC()()) {
821 out <<");" << std::endl;
822 } else {
823 out << "," << parGC.Data() <<");" << std::endl;
824 }
825 } else {
826 out << "," << parGC.Data() << "," << parFont.Data() <<");" << std::endl;
827 }
828 } else {
829 out << "," << parGC.Data() << "," << parFont.Data() << "," << GetOptionString() <<");" << std::endl;
830 }
831 } else {
832 out << "," << parGC.Data() << "," << parFont.Data() << "," << GetOptionString() << ",ucolor);" << std::endl;
833 }
834 if (option && strstr(option, "keep_names"))
835 out << " " << GetName() << "->SetName(\"" << GetName() << "\");" << std::endl;
836
838 TGLayoutManager * lm;
839 for (Int_t i=0; i<GetNumberOfTabs(); i++) {
840 cf = GetTabContainer(i);
841 if (!cf || !GetTabTab(i)) continue;
842 out << std::endl << " // container of " << quote
843 << GetTabTab(i)->GetString() << quote << std::endl;
844 out << " TGCompositeFrame *" << cf->GetName() << ";" << std::endl;
845 out << " " << cf->GetName() << " = " << GetName()
846 << "->AddTab(" << quote << GetTabTab(i)->GetString()
847 << quote << ");" << std::endl;
848 lm = cf->GetLayoutManager();
849 if (lm) {
850 if ((cf->GetOptions() & kHorizontalFrame) &&
852 ;
853 } else if ((GetOptions() & kVerticalFrame) &&
855 ;
856 } else {
857 out << " " << cf->GetName() <<"->SetLayoutManager(";
858 lm->SavePrimitive(out, option);
859 out << ");" << std::endl;
860 }
861 if (!IsEnabled(i)) {
862 out << " " << GetName() << "->SetEnabled(" << i << ", kFALSE);" << std::endl;
863 }
864 }
866
867 if (GetTabTab(i)->IsCloseShown()) {
868 out << " TGTabElement *tab" << i << " = "
869 << GetName() << "->GetTabTab(" << i << ");" << std::endl;
870 out << " tab" << i << "->ShowClose(kTRUE);" << std::endl;
871 }
874 out << " TGTabElement *tab" << i << " = "
875 << GetName() << "->GetTabTab(" << i << ");" << std::endl;
876 out << " tab" << i << "->ChangeBackground(ucolor);" << std::endl;
877 }
878
879 }
880 out << std::endl << " " << GetName() << "->SetTab(" << GetCurrent() << ");" << std::endl;
881 out << std::endl << " " << GetName() << "->Resize(" << GetName()
882 << "->GetDefaultSize());" << std::endl;
883}
884
885// __________________________________________________________________________
886void TGTabLayout::SavePrimitive(std::ostream &out, Option_t * /*= ""*/)
887{
888 // Save tab layout manager as a C++ statement(s) on out stream.
889
890 out << "new TGTabLayout(" << fMain->GetName() << ")";
891
892}
@ kButtonPress
Definition GuiTypes.h:60
const Mask_t kButtonPressMask
Definition GuiTypes.h:161
Handle_t Window_t
Window handle.
Definition GuiTypes.h:29
const Mask_t kAnyModifier
Definition GuiTypes.h:210
Handle_t GContext_t
Graphics context handle.
Definition GuiTypes.h:38
const Mask_t kPointerMotionMask
Definition GuiTypes.h:163
@ kChildFrame
Definition GuiTypes.h:379
@ kRaisedFrame
Definition GuiTypes.h:384
@ kVerticalFrame
Definition GuiTypes.h:381
@ kDoubleBorder
Definition GuiTypes.h:385
@ kHorizontalFrame
Definition GuiTypes.h:382
const Handle_t kNone
Definition GuiTypes.h:88
ULong_t Pixel_t
Pixel value.
Definition GuiTypes.h:40
@ kButton4
Definition GuiTypes.h:215
@ kButton5
Definition GuiTypes.h:215
@ kAnyButton
Definition GuiTypes.h:214
Handle_t FontStruct_t
Pointer to font structure.
Definition GuiTypes.h:39
int main()
Definition Prototype.cxx:12
#define c(i)
Definition RSha256.hxx:101
#define h(i)
Definition RSha256.hxx:106
size_t size(const MatrixT &matrix)
retrieve the size of a square matrix
int Int_t
Definition RtypesCore.h:45
unsigned int UInt_t
Definition RtypesCore.h:46
constexpr Bool_t kFALSE
Definition RtypesCore.h:101
constexpr Bool_t kTRUE
Definition RtypesCore.h:100
const char Option_t
Definition RtypesCore.h:66
#define ClassImp(name)
Definition Rtypes.h:377
#define gClient
Definition TGClient.h:156
winID h TVirtualViewer3D TVirtualGLPainter p
Option_t Option_t option
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void on
Option_t Option_t TPoint TPoint const char text
char name[80]
Definition TGX11.cxx:110
#define gVirtualX
Definition TVirtualX.h:337
Int_t MK_MSG(EWidgetMessageTypes msg, EWidgetMessageTypes submsg)
@ kCM_TAB
@ kC_COMMAND
void ProcessLine(TString cmd, Long_t msg, Long_t parm1, Long_t parm2)
Execute string "cmd" via the interpreter.
Definition TGClient.cxx:914
const TGPicture * GetPicture(const char *name)
Get picture from the picture pool.
Definition TGClient.cxx:289
void NeedRedraw(TGWindow *w, Bool_t force=kFALSE)
Set redraw flags.
Definition TGClient.cxx:372
The base class for composite widgets (menu bars, list boxes, etc.).
Definition TGFrame.h:287
TGLayoutManager * fLayoutManager
layout manager
Definition TGFrame.h:291
virtual void SetLayoutManager(TGLayoutManager *l)
Set the layout manager for the composite frame.
Definition TGFrame.cxx:1000
virtual void AddFrame(TGFrame *f, TGLayoutHints *l=nullptr)
Add frame to the composite frame using the specified layout hints.
Definition TGFrame.cxx:1117
virtual TList * GetList() const
Definition TGFrame.h:310
virtual TGLayoutManager * GetLayoutManager() const
Definition TGFrame.h:338
virtual void Cleanup()
Cleanup and delete all objects contained in this composite frame.
Definition TGFrame.cxx:967
virtual void SavePrimitiveSubframes(std::ostream &out, Option_t *option="")
Auxiliary protected method used to save subframes.
Definition TGFrame.cxx:2667
TList * fList
container of frame elements
Definition TGFrame.h:292
virtual void RemoveFrame(TGFrame *f)
Remove frame from composite frame.
Definition TGFrame.cxx:1149
void SetEditDisabled(UInt_t on=1) override
Set edit disable flag for this frame and subframes.
Definition TGFrame.cxx:1022
UInt_t fHeight
Definition TGDimension.h:21
UInt_t fWidth
Definition TGDimension.h:20
Encapsulate fonts used in the GUI system.
Definition TGFont.h:140
FontStruct_t GetFontStruct() const
Definition TGFont.h:184
void SavePrimitive(std::ostream &out, Option_t *="") override
Save the used font as a C++ statement(s) on output stream out.
Definition TGFont.cxx:1884
TGFrame * fFrame
Definition TGLayout.h:112
A subclasses of TGWindow, and is used as base class for some simple widgets (buttons,...
Definition TGFrame.h:80
virtual TGDimension GetDefaultSize() const
std::cout << fWidth << "x" << fHeight << std::endl;
Definition TGFrame.cxx:584
void MoveResize(Int_t x, Int_t y, UInt_t w=0, UInt_t h=0) override
Move and/or resize the frame.
Definition TGFrame.cxx:629
static const TGGC & GetBlackGC()
Get black graphics context.
Definition TGFrame.cxx:735
void Resize(UInt_t w=0, UInt_t h=0) override
Resize the frame.
Definition TGFrame.cxx:605
Int_t GetBorderWidth() const
Definition TGFrame.h:233
UInt_t fHeight
frame height
Definition TGFrame.h:88
virtual UInt_t GetDefaultWidth() const
Definition TGFrame.h:190
Int_t fBorderWidth
frame border width
Definition TGFrame.h:93
void MapWindow() override
map window
Definition TGFrame.h:204
static const TGGC & GetHilightGC()
Get highlight color graphics context.
Definition TGFrame.cxx:755
static Pixel_t GetDefaultFrameBackground()
Get default frame background.
Definition TGFrame.cxx:683
virtual UInt_t GetOptions() const
Definition TGFrame.h:197
TString GetOptionString() const
Returns a frame option string - used in SavePrimitive().
Definition TGFrame.cxx:2506
void UnmapWindow() override
unmap window
Definition TGFrame.h:206
virtual void SendMessage(const TGWindow *w, Longptr_t msg, Longptr_t parm1, Longptr_t parm2)
Send message (i.e.
Definition TGFrame.cxx:645
static const TGGC & GetShadowGC()
Get shadow color graphics context.
Definition TGFrame.cxx:765
UInt_t fWidth
frame width
Definition TGFrame.h:87
UInt_t GetHeight() const
Definition TGFrame.h:225
virtual void Layout()
Definition TGFrame.h:199
virtual Pixel_t GetBackground() const
Definition TGFrame.h:192
UInt_t GetWidth() const
Definition TGFrame.h:224
void SaveUserColor(std::ostream &out, Option_t *)
Save a user color in a C++ macro file - used in SavePrimitive().
Definition TGFrame.cxx:2479
Pixel_t fBackground
frame background color
Definition TGFrame.h:95
Encapsulate a graphics context used in the low level graphics.
Definition TGGC.h:22
void SavePrimitive(std::ostream &out, Option_t *option="") override
Save graphics context info as a C++ statement(s) on output stream out.
Definition TGGC.cxx:627
static TClass * Class()
Frame layout manager.
Definition TGLayout.h:135
TClass * IsA() const override
Definition TGLayout.h:149
virtual void Layout()=0
TGClient * fClient
Connection to display server.
Definition TGObject.h:25
Handle_t GetId() const
Definition TGObject.h:41
Handle_t fId
X11/Win32 Window identifier.
Definition TGObject.h:24
void Draw(Option_t *="") override
Default Draw method for all objects.
Definition TGPicture.h:46
TGString wraps a TString and adds some graphics routines like drawing, size of string on screen depen...
Definition TGString.h:20
Int_t GetLength() const
Definition TGString.h:29
const char * GetString() const
Definition TGString.h:30
virtual void Draw(Drawable_t id, GContext_t gc, Int_t x, Int_t y)
Draw string.
Definition TGString.cxx:56
Service classes of the tab widget.
Definition TGTab.h:117
TGDimension GetDefaultSize() const override
Return default size of tab element.
Definition TGTab.cxx:202
Bool_t fActive
true if active (in front)
Definition TGTab.h:129
Bool_t fShowClose
show or hide close icon
Definition TGTab.h:128
TGString * fText
text on tab
Definition TGTab.h:120
void SetText(TGString *text)
Set new tab text.
Definition TGTab.cxx:213
Bool_t HandleButton(Event_t *event) override
Handle button event in the tab widget.
Definition TGTab.cxx:141
GContext_t fNormGC
graphics context for drawing tab
Definition TGTab.h:123
virtual void SetEnabled(Bool_t on=kTRUE)
Definition TGTab.h:149
~TGTabElement() override
Delete tab element.
Definition TGTab.cxx:97
Bool_t fEnabled
enabled or disabled
Definition TGTab.h:127
const char * GetString() const
Definition TGTab.h:146
UInt_t fTHeight
height of tab text
Definition TGTab.h:126
FontStruct_t fFontStruct
font used for tab
Definition TGTab.h:124
const TGPicture * fClosePic
"close tab" icon
Definition TGTab.h:121
UInt_t fTWidth
width of tab text
Definition TGTab.h:125
const TGString * GetText() const
Definition TGTab.h:145
TGTabElement(const TGTabElement &)=delete
virtual void SetActive(Bool_t on=kTRUE)
Definition TGTab.h:154
const TGPicture * fClosePicD
"close tab" icon (disabled)
Definition TGTab.h:122
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:230
Bool_t IsEnabled() const
Definition TGTab.h:150
void DrawBorder() override
Draw little tab element.
Definition TGTab.cxx:107
Service classes of the tab widget.
Definition TGTab.h:24
TList * fList
Definition TGTab.h:28
void Layout() override
Layout the tab widget.
Definition TGTab.cxx:254
TGTab * fMain
Definition TGTab.h:27
void SavePrimitive(std::ostream &out, Option_t *option="") override
Save a primitive as a C++ statement(s) on output stream "out".
Definition TGTab.cxx:886
TGTabLayout(const TGTabLayout &)=delete
static TClass * Class()
TGDimension GetDefaultSize() const override
Get default size of tab widget.
Definition TGTab.cxx:298
A tab widget contains a set of composite frames each with a little tab with a name (like a set of fol...
Definition TGTab.h:46
static FontStruct_t GetDefaultFontStruct()
Return default font structure in use.
Definition TGTab.cxx:727
virtual void NewTab(const char *text="tab")
Create new tab. Used in context menu.
Definition TGTab.cxx:747
TGCompositeFrame * GetContainer() const
Definition TGTab.h:89
TGCompositeFrame * fContainer
main container
Definition TGTab.h:51
virtual void SetEnabled(Int_t tabIndex, Bool_t on=kTRUE)
Enable or disable tab.
Definition TGTab.cxx:470
virtual void SetText(const char *text="tab")
Set text to current tab.
Definition TGTab.cxx:762
TClass * IsA() const override
Definition TGTab.h:112
FontStruct_t fFontStruct
font
Definition TGTab.h:53
static const TGGC & GetDefaultGC()
Return default graphics context in use.
Definition TGTab.cxx:737
virtual void Removed(Int_t id)
Definition TGTab.h:108
TGTabElement * GetTabTab(Int_t tabIndex) const
Return the tab element of tab with index tabIndex.
Definition TGTab.cxx:663
Int_t fCurrent
index of current tab
Definition TGTab.h:49
~TGTab() override
Delete tab widget.
Definition TGTab.cxx:365
GContext_t fNormGC
drawing context
Definition TGTab.h:54
Int_t GetNumberOfTabs() const
Return number of tabs.
Definition TGTab.cxx:709
static const TGGC * fgDefaultGC
Definition TGTab.h:60
Bool_t fScrolling
true if tab scrolling enabled
Definition TGTab.h:55
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:558
Int_t GetCurrent() const
Definition TGTab.h:90
UInt_t fTabh
tab height
Definition TGTab.h:50
virtual void SetScrollingEnabled(Bool_t on=kTRUE)
Enable or disable tab scrolling.
Definition TGTab.cxx:490
void SavePrimitive(std::ostream &out, Option_t *option="") override
Save a tab widget as a C++ statement(s) on output stream out.
Definition TGTab.cxx:785
TList * fRemoved
list of removed tabs
Definition TGTab.h:52
virtual void RemoveTab(Int_t tabIndex=-1, Bool_t storeRemoved=kTRUE)
Remove container and tab of tab with index tabIndex.
Definition TGTab.cxx:427
virtual void Selected(Int_t id)
Definition TGTab.h:109
void ChangeTab(Int_t tabIndex, Bool_t emit=kTRUE)
Make tabIdx the current tab.
Definition TGTab.cxx:509
UInt_t GetTabHeight() const
Definition TGTab.h:97
TGCompositeFrame * GetTabContainer(Int_t tabIndex) const
Return container of tab with index tabIndex.
Definition TGTab.cxx:614
virtual TGCompositeFrame * AddTab(TGString *text)
Add a tab to the tab widget.
Definition TGTab.cxx:376
Bool_t IsScrollingEnabled() const
Returns true if tab scrolling is enabled.
Definition TGTab.cxx:482
TGTab(const TGTab &)=delete
TGTabElement * GetCurrentTab() const
Definition TGTab.h:96
TGLayoutManager * GetLayoutManager() const override
Return layout manager.
Definition TGTab.cxx:771
static const TGFont * fgDefaultFont
Definition TGTab.h:59
static TClass * Class()
TString fCommand
command to be executed
Definition TGWidget.h:49
const TGWindow * fMsgWindow
window which handles widget events
Definition TGWidget.h:48
Bool_t IsEnabled() const
Definition TGWidget.h:69
ROOT GUI Window base class.
Definition TGWindow.h:23
const TGWindow * fParent
Parent window.
Definition TGWindow.h:28
@ kEditDisableResize
window size cannot be edited
Definition TGWindow.h:61
@ kEditDisableLayout
window layout cannot be edited
Definition TGWindow.h:60
@ kEditDisableBtnEnable
window can handle mouse button events
Definition TGWindow.h:64
@ kEditDisableGrab
window grab cannot be edited
Definition TGWindow.h:59
@ kEditDisable
disable edit of this window
Definition TGWindow.h:57
virtual void LowerWindow()
lower window
Definition TGWindow.cxx:216
virtual void DestroyWindow()
destroy window
Definition TGWindow.cxx:192
virtual void RaiseWindow()
raise window
Definition TGWindow.cxx:208
const char * GetName() const override
Return unique name, used in SavePrimitive methods.
Definition TGWindow.cxx:336
UInt_t fEditDisabled
flags used for "guibuilding"
Definition TGWindow.h:32
A doubly linked list.
Definition TList.h:38
void Add(TObject *obj) override
Definition TList.h:83
void Delete(Option_t *option="") override
Remove all objects from the list AND delete all heap based objects.
Definition TList.cxx:468
virtual void SavePrimitive(std::ostream &out, Option_t *option="")
Save a primitive as a C++ statement(s) on output stream "out".
Definition TObject.cxx:751
virtual Bool_t InheritsFrom(const char *classname) const
Returns kTRUE if object inherits from class "classname".
Definition TObject.cxx:525
Basic string class.
Definition TString.h:139
const char * Data() const
Definition TString.h:376
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:2378
void Form(const char *fmt,...)
Formats a string using a printf style format descriptor.
Definition TString.cxx:2356
Short_t Max(Short_t a, Short_t b)
Returns the largest of a and b.
Definition TMathBase.h:250
Event structure.
Definition GuiTypes.h:174
EGEventType fType
of event (see EGEventType)
Definition GuiTypes.h:175
Int_t fY
pointer x, y coordinates in event window
Definition GuiTypes.h:178
Window_t fWindow
window reported event is relative to
Definition GuiTypes.h:176
Int_t fX
Definition GuiTypes.h:178
UInt_t fCode
key or button code
Definition GuiTypes.h:180