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