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