Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
TGLayout.cxx
Go to the documentation of this file.
1// @(#)root/gui:$Id$
2// Author: Fons Rademakers 02/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#include "TGLayout.h"
25#include "TGFrame.h"
26#include "TList.h"
27
28#include <iostream>
29
30
31
32
33////////////////////////////////////////////////////////////////////////////////
34/// Constructor.
35
37{
38 fLayout = 0;
39 fFrame = f;
40 if (f) f->SetFrameElement(this);
41
42 if (l) {
43 l->AddReference();
44 fLayout = l;
45 l->fPrev = l->fFE;
46 l->fFE = this;
47 }
48 fState = 1;
49}
50
51////////////////////////////////////////////////////////////////////////////////
52/// Destructor. Decrease ref. count of fLayout.
53
57
58////////////////////////////////////////////////////////////////////////////////
59/// Print this frame element.
60
62{
64
65 std::cout << "\t";
66 if (fFrame) {
67 std::cout << fFrame->ClassName() << "::" << fFrame->GetName();
68 }
69 if (fLayout) {
71 }
72 std::cout << std::endl;
73}
74
75////////////////////////////////////////////////////////////////////////////////
76/// Constructor.
77
79{
80 fPadleft = lh.fPadleft; fPadright = lh.fPadright;
81 fPadtop = lh.fPadtop; fPadbottom = lh.fPadbottom;
82 fLayoutHints = lh.fLayoutHints;
83 SetRefCount(0);
84 fFE = lh.fFE; fPrev = lh.fPrev;
85}
86
87////////////////////////////////////////////////////////////////////////////////
88/// Destructor.
89
93
94////////////////////////////////////////////////////////////////////////////////
95/// Update layout hints of frame elements.
96
98{
99 if (fFE) fFE->fLayout = l;
100 else return;
101
103
104 while (p && p->fLayout) {
105 p->fLayout = l;
106 p = p->fLayout->fPrev;
107 }
108}
109
110////////////////////////////////////////////////////////////////////////////////
111/// Printing.
112
114{
115 Bool_t bor = kFALSE;
116
118 std::cout << "kLHintsLeft";
119 bor = kTRUE;
120 }
122 if (bor) std::cout << " | ";
123 std::cout << "kLHintsCenterX";
124 bor = kTRUE;
125 }
127 if (bor) std::cout << " | ";
128 std::cout << "kLHintsRight";
129 bor = kTRUE;
130 }
131 if (fLayoutHints & kLHintsTop) {
132 if (bor) std::cout << " | ";
133 std::cout << "kLHintsTop";
134 bor = kTRUE;
135 }
137 if (bor) std::cout << " | ";
138 std::cout << "kLHintsCenterY";
139 bor = kTRUE;
140 }
142 if (bor) std::cout << " | ";
143 std::cout << "kLHintsBottom";
144 bor = kTRUE;
145 }
147 if (bor) std::cout << " | ";
148 std::cout << "kLHintsExpandX";
149 bor = kTRUE;
150 }
152 if (bor) std::cout << " | ";
153 std::cout << "kLHintsExpandY";
154 bor = kTRUE;
155 }
157 if (bor) std::cout << " | ";
158 std::cout << "kLHintsNoHints";
159 }
160 std::cout << ", fPadtop=" << fPadtop;
161 std::cout << ", fPadbottom=" << fPadbottom;
162 std::cout << ", fPadleft=" << fPadleft;
163 std::cout << ", fPadright=" << fPadright;
164 std::cout << std::endl;
165}
166
167////////////////////////////////////////////////////////////////////////////////
168/// Create vertical layout manager.
169
175
176////////////////////////////////////////////////////////////////////////////////
177/// Make a vertical layout of all frames in the list.
178
180{
181 TGFrameElement *ptr;
183 Int_t nb_expand = 0;
184 Int_t top, bottom;
187 Int_t exp = 0;
188 Int_t exp_max = 0;
190 Int_t x = 0, y = 0;
192 TGDimension size(0,0), csize(0,0);
196
197 if (!fList) return;
198
200
201 bottom = msize.fHeight - (top = bw);
202 remain = msize.fHeight - (bw << 1);
203
204 TIter next(fList);
205 while ((ptr = (TGFrameElement *) next())) {
206 if (ptr->fState & kIsVisible) {
207 layout = ptr->fLayout;
208 size = ptr->fFrame->GetDefaultSize();
209 size.fHeight += layout->GetPadTop() + layout->GetPadBottom();
210 hints = layout->GetLayoutHints();
211 if ((hints & kLHintsExpandY) || (hints & kLHintsCenterY)) {
212 nb_expand++;
213 exp += size.fHeight;
214 if (hints & kLHintsExpandY) exp_max = 0;
215 else exp_max = std::max(exp_max, (Int_t)size.fHeight);
216 } else {
217 remain -= size.fHeight;
218 if (remain < 0)
219 remain = 0;
220 }
221 }
222 }
223
224 if (nb_expand) {
226
227 if (size_expand < exp_max)
228 esize_expand = (remain - exp)/nb_expand;
230 }
231
232 next.Reset();
233 while ((ptr = (TGFrameElement *) next())) {
234 if (ptr->fState & kIsVisible) {
235 hints = (layout = ptr->fLayout)->GetLayoutHints();
236 csize = ptr->fFrame->GetDefaultSize();
237 pad_left = layout->GetPadLeft();
238 pad_top = layout->GetPadTop();
239 pad_right = layout->GetPadRight();
240 pad_bottom = layout->GetPadBottom();
241
242 if (hints & kLHintsRight) {
243 x = msize.fWidth - bw - csize.fWidth - pad_right;
244 } else if (hints & kLHintsCenterX) {
245 x = (msize.fWidth - (bw << 1) - csize.fWidth) >> 1;
246 } else { // defaults to kLHintsLeft
247 x = pad_left + bw;
248 }
249
250 if (hints & kLHintsExpandX) {
251 size.fWidth = msize.fWidth - (bw << 1) - pad_left - pad_right;
252 x = pad_left + bw;
253 } else {
254 size.fWidth = csize.fWidth;
255 }
256
257 if (hints & kLHintsExpandY) {
258 if (size_expand >= exp_max)
259 size.fHeight = size_expand - pad_top - pad_bottom;
260 else
261 size.fHeight = csize.fHeight + esize_expand;
262
264 if (tmp_expand >= nb_expand) {
265 size.fHeight++;
267 }
268 } else {
269 size.fHeight = csize.fHeight;
270 if (hints & kLHintsCenterY) {
271 if (size_expand >= exp_max) {
272 extra_space = (size_expand - pad_top - pad_bottom - size.fHeight) >> 1;
273 } else {
275 }
276 top += extra_space;
277 }
278 }
279
280 if (hints & kLHintsBottom) {
281 y = bottom - size.fHeight - pad_bottom;
282 bottom -= size.fHeight + pad_top + pad_bottom;
283 } else { // kLHintsTop by default
284 y = top + pad_top;
285 top += size.fHeight + pad_top + pad_bottom;
286 }
287
288 if (hints & kLHintsCenterY)
289 top += extra_space;
290
291 if (x > 32768) x = bw + 1;
292 //if (y > 32768) y = bw + 1;
293 if (size.fWidth > 32768)
294 size.fWidth = 1;
295 if (size.fHeight > 32768)
296 size.fHeight = 1;
297 ptr->fFrame->MoveResize(x, y, size.fWidth, size.fHeight);
298
299 fModified = fModified || (ptr->fFrame->GetX() != x) ||
300 (ptr->fFrame->GetY() != y) ||
301 (ptr->fFrame->GetWidth() != size.fWidth) ||
302 (ptr->fFrame->GetHeight() != size.fHeight);
303 }
304 }
305}
306
307////////////////////////////////////////////////////////////////////////////////
308/// Return default dimension of the vertical layout.
309
311{
312 TGFrameElement *ptr;
314 UInt_t options = fMain->GetOptions();
315
316 if ((options & kFixedWidth) && (options & kFixedHeight))
317 return msize;
318
319 TIter next(fList);
320 while ((ptr = (TGFrameElement *) next())) {
321 if (ptr->fState & kIsVisible) {
322 csize = ptr->fFrame->GetDefaultSize();
323 size.fWidth = std::max(size.fWidth, csize.fWidth + ptr->fLayout->GetPadLeft() +
324 ptr->fLayout->GetPadRight());
325 size.fHeight += csize.fHeight + ptr->fLayout->GetPadTop() +
326 ptr->fLayout->GetPadBottom();
327 }
328 }
329
330 size.fWidth += fMain->GetBorderWidth() << 1;
331 size.fHeight += fMain->GetBorderWidth() << 1;
332
333 if (options & kFixedWidth) size.fWidth = msize.fWidth;
334 if (options & kFixedHeight) size.fHeight = msize.fHeight;
335
336 return size;
337}
338
339////////////////////////////////////////////////////////////////////////////////
340/// Make a horizontal layout of all frames in the list.
341
343{
344 TGFrameElement *ptr;
346 Int_t nb_expand = 0;
347 Int_t left, right;
350 Int_t exp = 0;
351 Int_t exp_max = 0;
353 Int_t x = 0, y = 0;
359
360 if (!fList) return;
361
363 right = msize.fWidth - (left = bw);
364 remain = msize.fWidth - (bw << 1);
365
366 TIter next(fList);
367 while ((ptr = (TGFrameElement *) next())) {
368 if (ptr->fState & kIsVisible) {
369 layout = ptr->fLayout;
370 size = ptr->fFrame->GetDefaultSize();
371 size.fWidth += layout->GetPadLeft() + layout->GetPadRight();
372 hints = layout->GetLayoutHints();
373 if ((hints & kLHintsExpandX) || (hints & kLHintsCenterX)) {
374 nb_expand++;
375 exp += size.fWidth;
376 if (hints & kLHintsExpandX) exp_max = 0;
377 else exp_max = std::max(exp_max, (Int_t)size.fWidth);
378 } else {
379 remain -= size.fWidth;
380 if (remain < 0)
381 remain = 0;
382 }
383 }
384 }
385 if (nb_expand) {
387
388 if (size_expand < exp_max) {
389 esize_expand = (remain - exp)/nb_expand;
390 }
392 }
393
394 next.Reset();
395 while ((ptr = (TGFrameElement *) next())) {
396 if (ptr->fState & kIsVisible) {
397 hints = (layout = ptr->fLayout)->GetLayoutHints();
398 csize = ptr->fFrame->GetDefaultSize();
399 pad_left = layout->GetPadLeft();
400 pad_top = layout->GetPadTop();
401 pad_right = layout->GetPadRight();
402 pad_bottom = layout->GetPadBottom();
403
404 if (hints & kLHintsBottom) {
405 y = msize.fHeight - bw - csize.fHeight - pad_bottom;
406 } else if (hints & kLHintsCenterY) {
407 y = (msize.fHeight - (bw << 1) - csize.fHeight) >> 1;
408 } else { // kLHintsTop by default
409 y = pad_top + bw;
410 }
411
412 if (hints & kLHintsExpandY) {
413 size.fHeight = msize.fHeight - (bw << 1) - pad_top - pad_bottom;
414 y = pad_top + bw;
415 } else {
416 size.fHeight = csize.fHeight;
417 }
418
419 if (hints & kLHintsExpandX) {
420 if (size_expand >= exp_max)
421 size.fWidth = size_expand - pad_left - pad_right;
422 else
423 size.fWidth = csize.fWidth + esize_expand;
424
426
427 if (tmp_expand >= nb_expand) {
428 size.fWidth++;
430 }
431 } else {
432 size.fWidth = csize.fWidth;
433 if (hints & kLHintsCenterX) {
434 if (size_expand >= exp_max) {
435 extra_space = (size_expand - pad_left - pad_right - size.fWidth)>> 1;
436 } else {
438 }
439 left += extra_space;
440 }
441 }
442
443 if (hints & kLHintsRight) {
444 x = right - size.fWidth - pad_right;
445 right -= size.fWidth + pad_left + pad_right;
446 } else { // defaults to kLHintsLeft
447 x = left + pad_left;
448 left += size.fWidth + pad_left + pad_right;
449 }
450
451 if (hints & kLHintsCenterX)
452 left += extra_space;
453
454 ptr->fFrame->MoveResize(x, y, size.fWidth, size.fHeight);
455
456 fModified = fModified || (ptr->fFrame->GetX() != x) ||
457 (ptr->fFrame->GetY() != y) ||
458 (ptr->fFrame->GetWidth() != size.fWidth) ||
459 (ptr->fFrame->GetHeight() != size.fHeight);
460 }
461 }
462}
463
464////////////////////////////////////////////////////////////////////////////////
465/// Return default dimension of the horizontal layout.
466
468{
469 TGFrameElement *ptr;
471 UInt_t options = fMain->GetOptions();
472
473 if ((options & kFixedWidth) && (options & kFixedHeight))
474 return msize;
475
476 TIter next(fList);
477 while ((ptr = (TGFrameElement *) next())) {
478 if (ptr->fState & kIsVisible) {
479 csize = ptr->fFrame->GetDefaultSize();
480 size.fWidth += csize.fWidth + ptr->fLayout->GetPadLeft() +
481 ptr->fLayout->GetPadRight();
482
483 size.fHeight = std::max(size.fHeight, csize.fHeight + ptr->fLayout->GetPadTop() +
484 ptr->fLayout->GetPadBottom());
485 }
486 }
487 size.fWidth += fMain->GetBorderWidth() << 1;
488 size.fHeight += fMain->GetBorderWidth() << 1;
489
490 if (options & kFixedWidth) size.fWidth = msize.fWidth;
491 if (options & kFixedHeight) size.fHeight = msize.fHeight;
492
493 return size;
494}
495
496////////////////////////////////////////////////////////////////////////////////
497/// Make a row layout of all frames in the list.
498
500{
501 TGFrameElement *ptr;
504 Int_t x = bw, y = bw;
506
507 TIter next(fList);
508 while ((ptr = (TGFrameElement *) next())) {
509 if (ptr->fState & kIsVisible) {
510 size = ptr->fFrame->GetDefaultSize();
511 ptr->fFrame->Move(x, y);
512
513 fModified = fModified || (ptr->fFrame->GetX() != x) ||
514 (ptr->fFrame->GetY() != y);
515
516 ptr->fFrame->Layout();
517 x += size.fWidth + fSep;
518 }
519 }
520}
521
522////////////////////////////////////////////////////////////////////////////////
523/// Return default dimension of the row layout.
524
526{
527 TGFrameElement *ptr;
529 UInt_t options = fMain->GetOptions();
530
531 if ((options & kFixedHeight) && (options & kFixedWidth))
532 return msize;
533
534 TIter next(fList);
535 while ((ptr = (TGFrameElement *) next())) {
536 if (ptr->fState & kIsVisible) {
537 dsize = ptr->fFrame->GetDefaultSize();
538 size.fHeight = std::max(size.fHeight, dsize.fHeight);
539 size.fWidth += dsize.fWidth + fSep;
540 }
541 }
542
543 size.fHeight += fMain->GetBorderWidth() << 1;
544 size.fWidth += fMain->GetBorderWidth() << 1;
545 size.fWidth -= fSep;
546
547 if (options & kFixedHeight) size.fHeight = msize.fHeight;
548 if (options & kFixedWidth) size.fWidth = msize.fWidth;
549
550 return size;
551}
552
553////////////////////////////////////////////////////////////////////////////////
554/// Make a column layout of all frames in the list.
555
557{
558 TGFrameElement *ptr;
561 Int_t x = bw, y = bw;
563
564 TIter next(fList);
565 while ((ptr = (TGFrameElement *) next())) {
566 if (ptr->fState & kIsVisible) {
567 size = ptr->fFrame->GetDefaultSize();
568 ptr->fFrame->Move(x, y);
569 fModified = fModified || (ptr->fFrame->GetX() != x) ||
570 (ptr->fFrame->GetY() != y);
571 ptr->fFrame->Layout();
572 y += size.fHeight + fSep;
573 }
574 }
575}
576
577////////////////////////////////////////////////////////////////////////////////
578/// Return default dimension of the column layout.
579
581{
582 TGFrameElement *ptr;
584 UInt_t options = fMain->GetOptions();
585
586 if (options & kFixedHeight && options & kFixedWidth)
587 return msize;
588
589 TIter next(fList);
590 while ((ptr = (TGFrameElement *) next())) {
591 if (ptr->fState & kIsVisible) {
592 dsize = ptr->fFrame->GetDefaultSize();
593 size.fHeight += dsize.fHeight + fSep;
594 size.fWidth = std::max(size.fWidth, dsize.fWidth);
595 }
596 }
597
598 size.fHeight += fMain->GetBorderWidth() << 1;
599 size.fHeight -= fSep;
600 size.fWidth += fMain->GetBorderWidth() << 1;
601
602 if (options & kFixedHeight) size.fHeight = msize.fHeight;
603 if (options & kFixedWidth) size.fWidth = msize.fWidth;
604
605 return size;
606}
607
608////////////////////////////////////////////////////////////////////////////////
609/// TGMatrixLayout constructor.
610
612 Int_t s, Int_t h)
613{
614 fMain = main;
615 fList = fMain->GetList();
616 fSep = s;
617 fHints = h;
618 fRows = r;
619 fColumns = c;
620}
621
622////////////////////////////////////////////////////////////////////////////////
623/// Make a matrix layout of all frames in the list.
624
626{
627 TGFrameElement *ptr;
630 Int_t x = fSep, y = fSep + bw;
633
634 TIter next(fList);
635 while ((ptr = (TGFrameElement *) next())) {
636 csize = ptr->fFrame->GetDefaultSize();
637 maxsize.fWidth = std::max(maxsize.fWidth, csize.fWidth);
638 maxsize.fHeight = std::max(maxsize.fHeight, csize.fHeight);
639 }
640
641 next.Reset();
642 while ((ptr = (TGFrameElement *) next())) {
643 ptr->fFrame->Move(x, y);
644 fModified = fModified || (ptr->fFrame->GetX() != x) ||
645 (ptr->fFrame->GetY() != y);
646
647 ptr->fFrame->Layout();
648
649 if (fColumns == 0) {
650 y += maxsize.fHeight + fSep;
651 rowcount--;
652 if (rowcount <= 0) {
653 rowcount = fRows;
654 y = fSep + bw; x += maxsize.fWidth + fSep;
655 }
656 } else if (fRows == 0) {
657 x += maxsize.fWidth + fSep;
658 colcount--;
659 if (colcount <= 0) {
661 x = fSep; y += maxsize.fHeight + fSep;
662 }
663 } else {
664 x += maxsize.fWidth + fSep;
665 colcount--;
666 if (colcount <= 0) {
667 rowcount--;
668 if (rowcount <= 0) return;
669 else {
671 x = fSep; y += maxsize.fHeight + fSep;
672 }
673 }
674 }
675 }
676}
677
678////////////////////////////////////////////////////////////////////////////////
679/// Return default dimension of the matrix layout.
680
682{
683 TGFrameElement *ptr;
685 Int_t count = 0;
687
688 TIter next(fList);
689 while ((ptr = (TGFrameElement *) next())) {
690 count++;
691 csize = ptr->fFrame->GetDefaultSize();
692 maxsize.fWidth = std::max(maxsize.fWidth, csize.fWidth);
693 maxsize.fHeight = std::max(maxsize.fHeight, csize.fHeight);
694 }
695
696 if (fRows == 0) {
697 Int_t rows = (count % fColumns) ? (count / fColumns + 1) : (count / fColumns);
698 size.fWidth = fColumns * (maxsize.fWidth + fSep) + fSep;
699 size.fHeight = rows * (maxsize.fHeight + fSep) + fSep + bw;
700 } else if (fColumns == 0) {
701 Int_t cols = (count % fRows) ? (count / fRows + 1) : (count / fRows);
702 size.fWidth = cols * (maxsize.fWidth + fSep) + fSep;
703 size.fHeight = fRows * (maxsize.fHeight + fSep) + fSep + bw;
704 } else {
705 size.fWidth = fColumns * (maxsize.fWidth + fSep) + fSep;
706 size.fHeight = fRows * (maxsize.fHeight + fSep) + fSep + bw;
707 }
708 return size;
709}
710
711////////////////////////////////////////////////////////////////////////////////
712/// Create a tile layout manager.
713
721
722////////////////////////////////////////////////////////////////////////////////
723/// Make a tile layout of all frames in the list.
724
726{
727 TGFrameElement *ptr;
728 Int_t x, y, xw, yw;
733
734 TIter next(fList);
735 while ((ptr = (TGFrameElement *) next())) {
736 csize = ptr->fFrame->GetDefaultSize();
737 max_osize.fWidth = std::max(max_osize.fWidth, csize.fWidth);
738 max_osize.fHeight = std::max(max_osize.fHeight, csize.fHeight);
739 }
740
741 max_width = std::max(msize.fWidth, max_osize.fWidth + (fSep << 1));
742 x = fSep; y = fSep << 1;
743
744 next.Reset();
745 while ((ptr = (TGFrameElement *) next())) {
746 hints = ptr->fLayout->GetLayoutHints();
747 csize = ptr->fFrame->GetDefaultSize();
748
749 if (hints & kLHintsCenterX)
750 xw = x + (Int_t)((max_osize.fWidth - csize.fWidth) >> 1);
751 else if (hints & kLHintsRight)
752 xw = x + (Int_t)max_osize.fWidth - (Int_t)csize.fWidth;
753 else // defaults to kLHintsLeft
754 xw = x;
755
756 if (hints & kLHintsCenterY)
757 yw = y + (Int_t)((max_osize.fHeight - csize.fHeight) >> 1);
758 else if (hints & kLHintsBottom)
759 yw = y + (Int_t)max_osize.fHeight - (Int_t)csize.fHeight;
760 else // defaults to kLHintsTop
761 yw = y;
762
763 fModified = fModified || (ptr->fFrame->GetX() != xw) ||
764 (ptr->fFrame->GetY() != yw);
765 ptr->fFrame->Move(xw, yw);
766 if (hints & kLHintsExpandX)
767 ptr->fFrame->Resize(max_osize.fWidth, ptr->fFrame->GetDefaultHeight());
768 x += (Int_t)max_osize.fWidth + fSep;
769
770 if (x + max_osize.fWidth > max_width) {
771 x = fSep;
772 y += (Int_t)max_osize.fHeight + fSep + (fSep >> 1);
773 }
774 }
775}
776
777////////////////////////////////////////////////////////////////////////////////
778/// Return default dimension of the tile layout.
779
781{
782 TGFrameElement *ptr;
783 Int_t x, y;
784 TGDimension max_size, max_osize(0,0), msize = fMain->GetSize();
785
786 TIter next(fList);
787 while ((ptr = (TGFrameElement *) next())) {
788 max_size = ptr->fFrame->GetDefaultSize();
789 max_osize.fWidth = std::max(max_osize.fWidth, max_size.fWidth);
790 max_osize.fHeight = std::max(max_osize.fHeight, max_size.fHeight);
791 }
792
793 max_size.fWidth = std::max(msize.fWidth, max_osize.fWidth + (fSep << 1));
794
795 x = fSep; y = fSep << 1;
796
797 next.Reset();
798 // coverity[returned_pointer]
799 while (next()) {
800 x += max_osize.fWidth + fSep;
801 if (x + max_osize.fWidth > max_size.fWidth) {
802 x = fSep;
803 y += (Int_t)max_osize.fHeight + fSep + (fSep >> 1); // 3/2
804 }
805 }
806 if (x != fSep) y += max_osize.fHeight + fSep;
807 max_size.fHeight = std::max(y, (Int_t)msize.fHeight);
808
809 return max_size;
810}
811
812////////////////////////////////////////////////////////////////////////////////
813/// Make a tile layout of all frames in the list.
814
816{
817 TGFrameElement *ptr;
818 Int_t x, y, xw, yw;
823
824 TIter next(fList);
825 // coverity[returned_pointer]
826 while ((ptr = (TGFrameElement *) next())) {
827 csize = ptr->fFrame->GetDefaultSize();
828 max_osize.fWidth = std::max(max_osize.fWidth, csize.fWidth);
829 max_osize.fHeight = std::max(max_osize.fHeight, csize.fHeight);
830 }
831
832 max_height = std::max(msize.fHeight, max_osize.fHeight + (fSep << 1));
833
834 x = fSep; y = fSep << 1;
835
836 next.Reset();
837 while ((ptr = (TGFrameElement *) next())) {
838
839 hints = ptr->fLayout->GetLayoutHints();
840 csize = ptr->fFrame->GetDefaultSize();
841
842 if (hints & kLHintsCenterX)
843 xw = x + (Int_t)((max_osize.fWidth - csize.fWidth) >> 1);
844 else if (hints & kLHintsRight)
845 xw = x + (Int_t)max_osize.fWidth - (Int_t)csize.fWidth;
846 else // defaults to kLHintsLeft
847 xw = x;
848
849 if (hints & kLHintsCenterY)
850 yw = y + (Int_t)((max_osize.fHeight - csize.fHeight) >> 1);
851 else if (hints & kLHintsBottom)
852 yw = y + (Int_t)max_osize.fHeight - (Int_t)csize.fHeight;
853 else // defaults to kLHintsTop
854 yw = y;
855
856 fModified = fModified || (ptr->fFrame->GetX() != xw) ||
857 (ptr->fFrame->GetY() != yw);
858 ptr->fFrame->Move(xw, yw);
859 if (hints & kLHintsExpandX)
860 ptr->fFrame->Resize(max_osize.fWidth, ptr->fFrame->GetDefaultHeight());
861 y += (Int_t)max_osize.fHeight + fSep + (fSep >> 1);
862
863 if (y + max_osize.fHeight > max_height) {
864 y = fSep << 1;
865 x += (Int_t)max_osize.fWidth + fSep;
866 }
867 }
868}
869
870////////////////////////////////////////////////////////////////////////////////
871/// Return default dimension of the list layout.
872
874{
875 TGFrameElement *ptr;
876 Int_t x, y;
877 TGDimension max_size, max_osize(0,0), msize = fMain->GetSize();
878
879 TIter next(fList);
880 while ((ptr = (TGFrameElement *) next())) {
881 max_size = ptr->fFrame->GetDefaultSize();
882 max_osize.fWidth = std::max(max_osize.fWidth, max_size.fWidth);
883 max_osize.fHeight = std::max(max_osize.fHeight, max_size.fHeight);
884 }
885
886 max_size.fHeight = std::max(msize.fHeight, max_osize.fHeight + (fSep << 1));
887
888 x = fSep; y = fSep << 1;
889
890 next.Reset();
891 while (next()) {
892 y += (Int_t)max_osize.fHeight + fSep + (fSep >> 1);
893 if (y + max_osize.fHeight > max_size.fHeight) {
894 y = fSep << 1;
895 x += (Int_t)max_osize.fWidth + fSep;
896 }
897 }
898 if (y != (fSep << 1)) x += (Int_t)max_osize.fWidth + fSep;
899 max_size.fWidth = std::max(x, (Int_t)msize.fWidth);
900
901 return max_size;
902}
903
904////////////////////////////////////////////////////////////////////////////////
905/// Make a list details layout of all frames in the list.
906
908{
909 TGFrameElement *ptr;
911 Int_t max_oh = 0, x = fSep, y = fSep << 1;
913
914 TIter next(fList);
915 while ((ptr = (TGFrameElement *) next())) {
916 csize = ptr->fFrame->GetDefaultSize();
917 max_oh = std::max(max_oh, (Int_t)csize.fHeight);
918 }
919
920 next.Reset();
921
922 while ((ptr = (TGFrameElement *) next())) {
923 if (ptr->fState & kIsVisible) {
924 csize = ptr->fFrame->GetDefaultSize();
925
926 fModified = fModified || (ptr->fFrame->GetX() != x) ||
927 (ptr->fFrame->GetY() != y);
928
929 ptr->fFrame->MoveResize(x, y, msize.fWidth, csize.fHeight);
930 ptr->fFrame->Layout();
931 y += max_oh + fSep + (fSep >> 1);
932 }
933 }
934}
935
936////////////////////////////////////////////////////////////////////////////////
937/// Return default dimension of the list details layout.
938
940{
941 TGFrameElement *ptr;
943 Int_t y = fSep << 1;
944
945 TIter next(fList);
946 while ((ptr = (TGFrameElement *) next())) {
947 csize = ptr->fFrame->GetDefaultSize();
948 max_osize.fWidth = std::max(max_osize.fWidth, csize.fWidth);
949 max_osize.fHeight = std::max(max_osize.fHeight, csize.fHeight);
950 }
951
952 next.Reset();
953 while ((ptr = (TGFrameElement *) next())) {
954 if (ptr->fState & kIsVisible) {
955 y += max_osize.fHeight + fSep + (fSep >> 1);
956 }
957 }
958
959 return TGDimension( fWidth ? fWidth : max_osize.fWidth, y);
960}
961
962////////////////////////////////////////////////////////////////////////////////
963/// Save layout hints as a C++ statement(s) on output stream out
964
965void TGLayoutHints::SavePrimitive(std::ostream &out, Option_t * option/*= ""*/)
966{
968
969 if (!GetLayoutHints())
970 return;
971
972 if ((option == 0) || strcmp(option, "nocoma"))
973 out << ", ";
974
975 if ((fLayoutHints == kLHintsNormal) && (pad == 0)) {
976 out << "new TGLayoutHints(kLHintsNormal)";
977 return;
978 }
979
981 auto add = [this, &hints](UInt_t mask, const char *name) {
982 if (fLayoutHints & mask) {
983 if (hints.Length())
984 hints.Append(" | ");
985 hints.Append(name);
986 }
987 };
988 add(kLHintsLeft, "kLHintsLeft");
989 add(kLHintsCenterX, "kLHintsCenterX");
990 add(kLHintsRight, "kLHintsRight");
991 add(kLHintsTop, "kLHintsTop");
992 add(kLHintsCenterY, "kLHintsCenterY");
993 add(kLHintsBottom, "kLHintsBottom");
994 add(kLHintsExpandX, "kLHintsExpandX");
995 add(kLHintsExpandY, "kLHintsExpandY");
996
997 out << "new TGLayoutHints(" << hints;
998
999 if (pad)
1000 out << "," << GetPadLeft() << "," << GetPadRight() << "," << GetPadTop() << "," << GetPadBottom();
1001 out << ")";
1002}
1003
1004////////////////////////////////////////////////////////////////////////////////
1005/// Save vertical layout manager as a C++ statement(s) on output stream
1006
1007void TGVerticalLayout::SavePrimitive(std::ostream &out, Option_t * /*= ""*/)
1008{
1009 out << "new TGVerticalLayout(" << fMain->GetName() << ")";
1010}
1011
1012////////////////////////////////////////////////////////////////////////////////
1013/// Save horizontal layout manager as a C++ statement(s) on output stream
1014
1015void TGHorizontalLayout::SavePrimitive(std::ostream &out, Option_t * /*= ""*/)
1016{
1017 out << "new TGHorizontalLayout(" << fMain->GetName() << ")";
1018}
1019
1020////////////////////////////////////////////////////////////////////////////////
1021/// Save row layout manager as a C++ statement(s) on output stream
1022
1023void TGRowLayout::SavePrimitive(std::ostream &out, Option_t * /*= ""*/)
1024{
1025
1026 out << "new TGRowLayout(" << fMain->GetName() << "," << fSep << ")";
1027}
1028
1029////////////////////////////////////////////////////////////////////////////////
1030/// Save column layout manager as a C++ statement(s) on output stream
1031
1032void TGColumnLayout::SavePrimitive(std::ostream &out, Option_t * /*= ""*/)
1033{
1034
1035 out << "new TGColumnLayout(" << fMain->GetName() << "," << fSep << ")";
1036}
1037
1038////////////////////////////////////////////////////////////////////////////////
1039/// Save matrix layout manager as a C++ statement(s) on output stream
1040
1041void TGMatrixLayout::SavePrimitive(std::ostream &out, Option_t * /*= ""*/)
1042{
1043
1044 out << "new TGMatrixLayout(" << fMain->GetName() << "," << fRows << "," << fColumns << "," << fSep << "," << fHints
1045 << ")";
1046}
1047
1048////////////////////////////////////////////////////////////////////////////////
1049/// Save tile layout manager as a C++ statement(s) on output stream
1050
1051void TGTileLayout::SavePrimitive(std::ostream &out, Option_t * /*= ""*/)
1052{
1053
1054 out << "new TGTileLayout(" << fMain->GetName() << "," << fSep << ")";
1055}
1056
1057////////////////////////////////////////////////////////////////////////////////
1058/// Save list layout manager as a C++ statement(s) on output stream
1059
1060void TGListLayout::SavePrimitive(std::ostream &out, Option_t * /*= ""*/)
1061{
1062
1063 out << "new TGListLayout(" << fMain->GetName() << "," << fSep << ")";
1064}
1065
1066////////////////////////////////////////////////////////////////////////////////
1067/// Save list details layout manager as a C++ statement(s) on out stream
1068
1069void TGListDetailsLayout::SavePrimitive(std::ostream &out, Option_t * /*= ""*/)
1070{
1071
1072 out << "new TGListDetailsLayout(" << fMain->GetName() << "," << fSep << "," << fWidth << ")";
1073}
@ kFixedWidth
Definition GuiTypes.h:387
@ kFixedHeight
Definition GuiTypes.h:389
int main()
Definition Prototype.cxx:12
#define f(i)
Definition RSha256.hxx:104
#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
Signed integer 4 bytes (int)
Definition RtypesCore.h:59
unsigned long ULong_t
Unsigned long integer 4 bytes (unsigned long). Size depends on architecture.
Definition RtypesCore.h:69
constexpr Bool_t kFALSE
Definition RtypesCore.h:108
constexpr Bool_t kTRUE
Definition RtypesCore.h:107
const char Option_t
Option string (const char)
Definition RtypesCore.h:80
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
@ kIsVisible
Definition TGFrame.h:33
@ kLHintsNoHints
Definition TGLayout.h:23
@ kLHintsRight
Definition TGLayout.h:26
@ kLHintsExpandY
Definition TGLayout.h:31
@ kLHintsLeft
Definition TGLayout.h:24
@ kLHintsCenterY
Definition TGLayout.h:28
@ kLHintsNormal
Definition TGLayout.h:32
@ kLHintsCenterX
Definition TGLayout.h:25
@ kLHintsBottom
Definition TGLayout.h:29
@ kLHintsTop
Definition TGLayout.h:27
@ kLHintsExpandX
Definition TGLayout.h:30
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 char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t mask
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t r
char name[80]
Definition TGX11.cxx:110
void Layout() override
Make a column layout of all frames in the list.
Definition TGLayout.cxx:556
void SavePrimitive(std::ostream &out, Option_t *="") override
Save column layout manager as a C++ statement(s) on output stream.
TGDimension GetDefaultSize() const override
Return default dimension of the column layout.
Definition TGLayout.cxx:580
The base class for composite widgets (menu bars, list boxes, etc.).
Definition TGFrame.h:289
virtual TList * GetList() const
Definition TGFrame.h:312
UInt_t fHeight
Definition TGDimension.h:21
UInt_t fWidth
Definition TGDimension.h:20
TGLayoutHints * fLayout
Definition TGLayout.h:114
~TGFrameElement() override
Destructor. Decrease ref. count of fLayout.
Definition TGLayout.cxx:54
void Print(Option_t *option="") const override
Print this frame element.
Definition TGLayout.cxx:61
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:576
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:621
void Resize(UInt_t w=0, UInt_t h=0) override
Resize the frame.
Definition TGFrame.cxx:597
Int_t GetBorderWidth() const
Definition TGFrame.h:235
virtual UInt_t GetDefaultHeight() const
Definition TGFrame.h:193
TGDimension GetSize() const
Definition TGFrame.h:232
void Move(Int_t x, Int_t y) override
Move frame.
Definition TGFrame.cxx:585
Int_t GetX() const
Definition TGFrame.h:233
virtual UInt_t GetOptions() const
Definition TGFrame.h:199
void SetFrameElement(TGFrameElement *fe)
Definition TGFrame.h:238
UInt_t GetHeight() const
Definition TGFrame.h:227
Int_t GetY() const
Definition TGFrame.h:234
virtual void Layout()
Definition TGFrame.h:201
UInt_t GetWidth() const
Definition TGFrame.h:226
TGDimension GetDefaultSize() const override
Return default dimension of the horizontal layout.
Definition TGLayout.cxx:467
void SavePrimitive(std::ostream &out, Option_t *="") override
Save horizontal layout manager as a C++ statement(s) on output stream.
void Layout() override
Make a horizontal layout of all frames in the list.
Definition TGLayout.cxx:342
This class describes layout hints used by the layout classes.
Definition TGLayout.h:50
~TGLayoutHints() override
Destructor.
Definition TGLayout.cxx:90
TGFrameElement * fPrev
Definition TGLayout.h:57
Int_t GetPadRight() const
Definition TGLayout.h:86
void Print(Option_t *option="") const override
Printing.
Definition TGLayout.cxx:113
Int_t fPadtop
Definition TGLayout.h:63
void SavePrimitive(std::ostream &out, Option_t *option="") override
Save layout hints as a C++ statement(s) on output stream out.
Definition TGLayout.cxx:965
Int_t GetPadBottom() const
Definition TGLayout.h:84
Int_t fPadbottom
Definition TGLayout.h:64
TGLayoutHints(ULong_t hints=kLHintsNormal, Int_t padleft=0, Int_t padright=0, Int_t padtop=0, Int_t padbottom=0)
Definition TGLayout.h:71
ULong_t fLayoutHints
Definition TGLayout.h:62
ULong_t GetLayoutHints() const
Definition TGLayout.h:82
Int_t fPadleft
Definition TGLayout.h:65
Int_t GetPadTop() const
Definition TGLayout.h:83
TGFrameElement * fFE
Definition TGLayout.h:56
Int_t GetPadLeft() const
Definition TGLayout.h:85
Int_t fPadright
Definition TGLayout.h:66
void UpdateFrameElements(TGLayoutHints *l)
Update layout hints of frame elements.
Definition TGLayout.cxx:97
Bool_t fModified
Definition TGLayout.h:137
void SavePrimitive(std::ostream &out, Option_t *="") override
Save list details layout manager as a C++ statement(s) on out stream.
void Layout() override
Make a list details layout of all frames in the list.
Definition TGLayout.cxx:907
TGDimension GetDefaultSize() const override
Return default dimension of the list details layout.
Definition TGLayout.cxx:939
void Layout() override
Make a tile layout of all frames in the list.
Definition TGLayout.cxx:815
void SavePrimitive(std::ostream &out, Option_t *="") override
Save list layout manager as a C++ statement(s) on output stream.
TGDimension GetDefaultSize() const override
Return default dimension of the list layout.
Definition TGLayout.cxx:873
UInt_t fRows
number of rows
Definition TGLayout.h:282
void SavePrimitive(std::ostream &out, Option_t *="") override
Save matrix layout manager as a C++ statement(s) on output stream.
Int_t fHints
layout hints (currently not used)
Definition TGLayout.h:281
TGMatrixLayout(const TGMatrixLayout &)=delete
TGCompositeFrame * fMain
container frame
Definition TGLayout.h:276
Int_t fSep
interval between frames
Definition TGLayout.h:280
UInt_t fColumns
number of columns
Definition TGLayout.h:283
void Layout() override
Make a matrix layout of all frames in the list.
Definition TGLayout.cxx:625
TList * fList
list of frames to arrange
Definition TGLayout.h:277
TGDimension GetDefaultSize() const override
Return default dimension of the matrix layout.
Definition TGLayout.cxx:681
void SavePrimitive(std::ostream &out, Option_t *="") override
Save row layout manager as a C++ statement(s) on output stream.
Int_t fSep
Definition TGLayout.h:209
TGDimension GetDefaultSize() const override
Return default dimension of the row layout.
Definition TGLayout.cxx:525
void Layout() override
Make a row layout of all frames in the list.
Definition TGLayout.cxx:499
TGDimension GetDefaultSize() const override
Return default dimension of the tile layout.
Definition TGLayout.cxx:780
TList * fList
list of frames to arrange
Definition TGLayout.h:312
Int_t fSep
separation between tiles
Definition TGLayout.h:310
TGCompositeFrame * fMain
container frame
Definition TGLayout.h:311
void Layout() override
Make a tile layout of all frames in the list.
Definition TGLayout.cxx:725
Bool_t fModified
layout changed
Definition TGLayout.h:313
void SavePrimitive(std::ostream &out, Option_t *="") override
Save tile layout manager as a C++ statement(s) on output stream.
TGTileLayout(const TGTileLayout &)=delete
void Layout() override
Make a vertical layout of all frames in the list.
Definition TGLayout.cxx:179
TGVerticalLayout(const TGVerticalLayout &gvl)
Definition TGLayout.h:165
TGCompositeFrame * fMain
Definition TGLayout.h:162
void SavePrimitive(std::ostream &out, Option_t *="") override
Save vertical layout manager as a C++ statement(s) on output stream.
TGDimension GetDefaultSize() const override
Return default dimension of the vertical layout.
Definition TGLayout.cxx:310
const char * GetName() const override
Return unique name, used in SavePrimitive methods.
Definition TGWindow.cxx:334
void Reset()
Mother of all ROOT objects.
Definition TObject.h:41
virtual const char * ClassName() const
Returns name of class to which the object belongs.
Definition TObject.cxx:226
virtual void Print(Option_t *option="") const
This method must be overridden when a class wants to print itself.
Definition TObject.cxx:655
Definitions for TRefCnt, base class for reference counted objects.
Definition TRefCnt.h:27
void SetRefCount(UInt_t r)
Definition TRefCnt.h:39
Basic string class.
Definition TString.h:138
Double_t y[n]
Definition legend1.C:17
Double_t x[n]
Definition legend1.C:17
TLine l
Definition textangle.C:4