Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
TGTableLayout.cxx
Go to the documentation of this file.
1// @(#)root/gui:$Id$
2// Author: Brett Viren 04/15/2001
3
4/*************************************************************************
5 * Copyright (C) 2001, Brett Viren *
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 The Layout algorithm was largely translated from GTK's gtktable.c
25 source. That source is also distributed under LGPL.
26
27**************************************************************************/
28
29
30/** \class TGTableLayout
31 \ingroup guiwidgets
32
33A layout manager, which places child frames in a table arranged in
34rows and columns, making it easy to align many widgets next each to
35other horizontally and vertically. It uses TGTableLayoutHints
36(not TGLayoutHints!!!) and works like TGMatrixLayout with the
37addition that:
38 - Child frames can span more than one column/row.
39 - Child frames can resize with the frame.
40 - Column and row sizes are not fixed nor (optionally) homogeneous.
41 - The number of columns and rows must be fully specified in the constructor.
42The gaps between all rows or columns can be specified by 'sep'
43parameter in the constructor. All rows and columns will have the
44same size (set by widest and the highest child frame) if the
45parameter 'homogeneous' is set to kTRUE.
46
47
48\class TGTableLayoutHints
49\ingroup guiwidgets
50
51This class describes layout hints used by the TGTableLayout class.
52It specifies the column/row division number on which to attach the
53child frame. This number starts from 0 and goes to #%_columns/#%_rows
54respectively (0 indicates the first row/column).
55
56Below are described all parameters of TGTableLayoutHints constructor
57 - attach_left - the column to the left of the widget;
58 - attach_right - the column to the right of the widget;
59 - attach_top - the row above the widget;
60 - attach_bottom - the row below the widget;
61 - hints - layout hints (combination of ELayoutHints)
62
63The next parameters determine the extra padding added around the
64child frame. By default these are 0.
65 - padleft - determines the extra padding added on the left
66 - padright - determines the extra padding added on the right
67 - padtop - determines the extra padding added on the top
68 - padbottom - determines the extra padding added on the bottom
69
70*/
71
72
73#include "TGTableLayout.h"
74#include "TGFrame.h"
75#include "TList.h"
76#include "Rtypes.h"
77
78#include <iostream>
79
80
83
84////////////////////////////////////////////////////////////////////////////////
85/// TGTableLayout constructor.
86/// Note:
87/// - Number of rows first, number of Columns second
88/// - homogeneous == true means all table cells are the same size,
89/// set by the widest and the highest child frame.
90/// - s gives the amount of separation in pixels between cells
91/// - h are the hints, see TGTableLayoutHints.
92
94 Bool_t homogeneous, Int_t sep, Int_t hints)
95{
96 fMain = main;
97 fList = fMain->GetList();
98 fSep = sep;
99 fHints = hints;
100 fNrows = nrows;
101 fNcols = ncols;
102 fRow = 0;
103 fCol = 0;
104 fHomogeneous = homogeneous;
105}
106
107////////////////////////////////////////////////////////////////////////////////
108/// TGTableLayout constructor.
109
111{
112 if (fRow) delete [] fRow;
113 if (fCol) delete [] fCol;
114}
115
116////////////////////////////////////////////////////////////////////////////////
117/// Find the sizes of rows and columns needed to satisfy
118/// children's layout policies.
119
121{
122 // This is equiv. to GTK's requisition stage
123
129}
130
131////////////////////////////////////////////////////////////////////////////////
132/// Initialize values needed to determine the size of rows and columns.
133
135{
136 if (fRow) delete [] fRow;
137 if (fCol) delete [] fCol;
138 fRow = new TableData_t[fNrows];
139 fCol = new TableData_t[fNcols];
140
141 // Find max of each row and column
142
143 UInt_t i;
144 for (i = 0; i < fNrows; ++i) fRow[i].fDefSize = 0;
145 for (i = 0; i < fNcols; ++i) fCol[i].fDefSize = 0;
146}
147
148////////////////////////////////////////////////////////////////////////////////
149/// Determine the size of rows/cols needed for singly attached children.
150
152{
153 TIter next(fList);
154 TGFrameElement *ptr;
155
156 while ((ptr = (TGFrameElement *) next())) {
157 if (ptr->fState == 0) continue;
158 TGTableLayoutHints *layout =
159 dynamic_cast<TGTableLayoutHints*>(ptr->fLayout);
160 if (!layout) {
161 Error("FindRowColSizesSinglyAttached", "didn't get TGTableLayoutHints from %s, layout = 0x%zx",
162 ptr->fFrame->GetName(), (size_t)ptr->fLayout);
163 return;
164 }
165 UInt_t col = layout->GetAttachLeft();
166 if (col == (layout->GetAttachRight() - 1))
167 fCol[col].fDefSize = TMath::Max(fCol[col].fDefSize,
168 ptr->fFrame->GetDefaultWidth() +
169 layout->GetPadLeft() +
170 layout->GetPadRight());
171
172 UInt_t row = layout->GetAttachTop();
173 if (row == (layout->GetAttachBottom() - 1))
174 fRow[row].fDefSize = TMath::Max(fRow[row].fDefSize,
175 ptr->fFrame->GetDefaultHeight() +
176 layout->GetPadTop() +
177 layout->GetPadBottom());
178 }
179}
180
181////////////////////////////////////////////////////////////////////////////////
182/// If the table is homogeneous make sure all col/rows are same
183/// size as biggest col/row.
184
186{
187 if (!fHomogeneous) return;
188
189 UInt_t max_width = 0, max_height = 0, col, row;
190
191 // find max
192 for (col = 0; col < fNcols; ++col)
193 max_width = TMath::Max(max_width,fCol[col].fDefSize);
194
195 for (row = 0; row < fNrows; ++row)
196 max_height = TMath::Max(max_height,fRow[row].fDefSize);
197
198 // set max
199 for (col = 0; col < fNcols; ++col) fCol[col].fDefSize = max_width;
200 for (row = 0; row < fNrows; ++row) fRow[row].fDefSize = max_height;
201}
202
203////////////////////////////////////////////////////////////////////////////////
204/// Checks any children which span multiple col/rows.
205
207{
208 TIter next(fList);
209 TGFrameElement *ptr;
210
211 while ((ptr = (TGFrameElement *) next())) {
212 if (ptr->fState == 0) continue;
213 TGTableLayoutHints *layout =
214 dynamic_cast<TGTableLayoutHints*>(ptr->fLayout);
215 if (!layout) {
216 Error("FindRowColSizesMultiplyAttached", "didn't get TGTableLayoutHints");
217 return;
218 }
219 UInt_t left = layout->GetAttachLeft();
220 UInt_t right = layout->GetAttachRight();
221 if (left != right-1) { // child spans multi-columns
222 UInt_t width = 0, col;
223 for (col = left; col < right; ++col) width += fCol[col].fDefSize;
224
225 // If more space needed, divide space evenly among the columns
226 UInt_t child_width = ptr->fFrame->GetDefaultWidth() +
227 layout->GetPadLeft() + layout->GetPadRight();
228
229 if (width < child_width) {
230 width = child_width - width;
231 for (col = left; col < right; ++col) {
232 UInt_t extra = width / (right - col);
233 fCol[col].fDefSize += extra;
234 width -= extra;
235 }
236 }
237 }
238 UInt_t top = layout->GetAttachTop();
239 UInt_t bottom = layout->GetAttachBottom();
240 if (top != bottom-1) { // child spans multi-rows
241 UInt_t height = 0, row;
242 for (row = top; row < bottom; ++row) height += fRow[row].fDefSize;
243
244 // If more space needed, divide space evenly among the rows
245 UInt_t child_height = ptr->fFrame->GetDefaultHeight() +
246 layout->GetPadTop() + layout->GetPadBottom();
247
248 if (height < child_height) {
249 height = child_height - height;
250 for (row = top; row < bottom; ++row) {
251 UInt_t extra = height / (bottom - row);
252 fRow[row].fDefSize += extra;
253 height -= extra;
254 }
255 }
256 }
257 }
258}
259
260////////////////////////////////////////////////////////////////////////////////
261/// If main frame is bigger or smaller than all children,
262/// expand/shrink to fill. This is symmetric under row<-->col
263/// switching so it is abstracted out to a normal function to save typing.
264
266 TableData_t *thing, Bool_t homogeneous)
267{
268 if (homogeneous) {
269 UInt_t ind, nshrink=0, nexpand=0, cur_size=0;
270
271 for (ind = 0; ind < nthings; ++ind)
272 cur_size += thing[ind].fDefSize;
273
274 if (cur_size < real_size) {
275 for (ind = 0; ind < nthings; ++ind)
276 if (thing[ind].fExpand) { ++ nexpand; break; }
277 if (nexpand > 0) {
278 UInt_t size = real_size;
279 for (ind = 0; ind < nthings; ++ ind) {
280 UInt_t extra = size / (nthings - ind);
281 thing[ind].fRealSize = TMath::Max(1U, extra);
282 size -= extra;
283 }
284 }
285 }
286 if (cur_size > real_size) {
287 for (ind = 0; ind < nthings; ++ind)
288 if (thing[ind].fShrink) { ++ nshrink; break; }
289 if (nshrink > 0) {
290 UInt_t size = real_size;
291 for (ind = 0; ind < nthings; ++ ind) {
292 UInt_t extra = size / (nthings - ind);
293 thing[ind].fRealSize = TMath::Max(1U, extra);
294 size -= extra;
295 }
296 }
297 }
298 } else {
299 UInt_t ind, nshrink=0, nexpand=0, size=0;
300 for (ind = 0; ind < nthings; ++ind) {
301 size += thing[ind].fDefSize;
302 if (thing[ind].fExpand) ++ nexpand;
303 if (thing[ind].fShrink) ++ nshrink;
304 }
305
306 // Did main frame expand?
307 if ((size < real_size) && (nexpand >= 1)) {
308 size = real_size - size;
309 for (ind = 0; ind < nthings; ++ind) {
310 if (thing[ind].fExpand) {
311 UInt_t extra = size / nexpand;
312 thing[ind].fRealSize += extra;
313 size -= extra;
314 --nexpand;
315 }
316 }
317 }
318
319 // Did main frame shrink?
320 if (size > real_size) {
321 UInt_t total_nshrink = nshrink;
322 UInt_t extra = size - real_size;
323 while (total_nshrink > 0 && extra > 0) {
324 nshrink = total_nshrink;
325 for (ind = 0; ind < nthings; ++ind)
326 if (thing[ind].fShrink) {
327 UInt_t size2 = thing[ind].fRealSize;
328 thing[ind].fRealSize = TMath::Max(1U,thing[ind].fRealSize - extra / nshrink);
329 extra -= size2 - thing[ind].fRealSize;
330 --nshrink;
331 if (thing[ind].fRealSize < 2) {
332 total_nshrink -= 1;
333 thing[ind].fShrink = kFALSE;
334 }
335 }
336 }
337 }
338 } // not homogeneous
339}
340
341////////////////////////////////////////////////////////////////////////////////
342/// This gets the new sizes needed to fit the table to the parent
343/// frame. To be called after FindRowColSizes.
344
346{
348 UInt_t border_width = fMain->GetBorderWidth();
349
350 SetRowColResize(fMain->GetWidth() - (fNcols-1)*fSep - 2*border_width,
352 SetRowColResize(fMain->GetHeight() - (fNrows-1)*fSep - 2*border_width,
354}
355
356////////////////////////////////////////////////////////////////////////////////
357/// Initialize rows/cols. By default they do not expand and they
358/// do shrink. What the children want determine what the rows/cols do.
359
361{
362 UInt_t col;
363 for (col = 0; col < fNcols; ++col) {
364 fCol[col].fRealSize = fCol[col].fDefSize;
365 fCol[col].fNeedExpand = kFALSE;
366 fCol[col].fNeedShrink = kTRUE;
367 fCol[col].fExpand = kFALSE;
368 fCol[col].fShrink = kTRUE;
369 fCol[col].fEmpty = kTRUE;
370 }
371 UInt_t row;
372 for (row = 0; row < fNrows; ++row) {
373 fRow[row].fRealSize = fRow[row].fDefSize;
374 fRow[row].fNeedExpand = kFALSE;
375 fRow[row].fNeedShrink = kTRUE;
376 fRow[row].fExpand = kFALSE;
377 fRow[row].fShrink = kTRUE;
378 fRow[row].fEmpty = kTRUE;
379 }
380
381 // Check single row/col children for expand/shrink-ability
382 TIter next(fList);
383 TGFrameElement *ptr;
384 while ((ptr = (TGFrameElement*) next())) {
385 TGTableLayoutHints *layout =
386 dynamic_cast<TGTableLayoutHints*>(ptr->fLayout);
387 if (!layout) {
388 Error("SetRowColSizesInit", "didn't get TGTableLayoutHints");
389 return;
390 }
391 ULong_t hints = layout->GetLayoutHints();
392
393 // columns
394 if (layout->GetAttachLeft() == layout->GetAttachRight()-1) {
395 if (hints & kLHintsExpandX)
396 fCol[layout->GetAttachLeft()].fExpand = kTRUE;
397 if (!(hints & kLHintsShrinkX))
398 fCol[layout->GetAttachLeft()].fShrink = kFALSE;
399 fCol[layout->GetAttachLeft()].fEmpty = kFALSE;
400 }
401 // rows
402 if (layout->GetAttachTop() == layout->GetAttachBottom()-1) {
403 if (hints & kLHintsExpandY)
404 fRow[layout->GetAttachTop()].fExpand = kTRUE;
405 if (!(hints & kLHintsShrinkY))
406 fRow[layout->GetAttachTop()].fShrink = kFALSE;
407 fRow[layout->GetAttachTop()].fEmpty = kFALSE;
408 }
409 }
410
411 // Do same for children of spanning multiple col/rows
412 next.Reset();
413 while ((ptr = (TGFrameElement*) next())) {
414 TGTableLayoutHints *layout =
415 dynamic_cast<TGTableLayoutHints*>(ptr->fLayout);
416 if (!layout) {
417 Error("SetRowColSizesInit", "didn't get TGTableLayoutHints");
418 return;
419 }
420 ULong_t hints = layout->GetLayoutHints();
421
422 // columns
423 UInt_t left = layout->GetAttachLeft();
424 UInt_t right = layout->GetAttachRight();
425 if (left != right - 1) {
426 for (col = left; col < right; ++col) fCol[col].fEmpty = kFALSE;
427 Bool_t has_expand=kFALSE, has_shrink=kTRUE;
428 if (hints & kLHintsExpandX) {
429 for (col = left; col < right; ++col)
430 if (fCol[col].fExpand) { has_expand = kTRUE; break; }
431 if (!has_expand)
432 for (col = left; col < right; ++col)
433 fCol[col].fNeedExpand = kTRUE;
434 }
435 if (!(hints & kLHintsShrinkX)) {
436 for (col = left; col < right; ++col)
437 if (!fCol[col].fShrink) { has_shrink = kFALSE; break;}
438 if (has_shrink)
439 for (col = left; col < right; ++col)
440 fCol[col].fNeedShrink = kFALSE;
441 }
442 }
443
444 // rows
445 UInt_t top = layout->GetAttachTop();
446 UInt_t bottom = layout->GetAttachBottom();
447 if (top != bottom - 1) {
448 for (row = top; row < bottom; ++row) fRow[row].fEmpty = kFALSE;
449 Bool_t has_expand=kFALSE, has_shrink=kTRUE;
450 if (hints & kLHintsExpandY) {
451 for (row = top; row < bottom; ++row)
452 if (fRow[row].fExpand) { has_expand = kTRUE; break; }
453 if (!has_expand)
454 for (row = top; row < bottom; ++row)
455 fRow[row].fNeedExpand = kTRUE;
456 }
457 if (!(hints & kLHintsShrinkY)) {
458 for (row = top; row < bottom; ++row)
459 if (!fRow[row].fShrink) { has_shrink = kFALSE; break;}
460 if (has_shrink)
461 for (row = top; row < bottom; ++row)
462 fRow[row].fNeedShrink = kFALSE;
463 }
464 }
465 }
466
467 // Set expand/shrink flags
468 for (col = 0; col < fNcols; ++col) {
469 if (fCol[col].fEmpty) {
470 fCol[col].fExpand = kFALSE;
471 fCol[col].fShrink = kFALSE;
472 } else {
473 if (fCol[col].fNeedExpand) fCol[col].fExpand = kTRUE;
474 if (!fCol[col].fNeedShrink) fCol[col].fShrink = kFALSE;
475 }
476 }
477 for (row = 0; row < fNrows; ++row) {
478 if (fRow[row].fEmpty) {
479 fRow[row].fExpand = kFALSE;
480 fRow[row].fShrink = kFALSE;
481 } else {
482 if (fRow[row].fNeedExpand) fRow[row].fExpand = kTRUE;
483 if (!fRow[row].fNeedShrink) fRow[row].fShrink = kFALSE;
484 }
485 }
486}
487
488////////////////////////////////////////////////////////////////////////////////
489/// Sanity check various values.
490
492{
493 TIter next(fList);
494 TGFrameElement *ptr;
495 UInt_t nerrors = 0;
496 while ((ptr = (TGFrameElement*) next())) {
497 TGTableLayoutHints *layout =
498 dynamic_cast<TGTableLayoutHints*>(ptr->fLayout);
499 if (!layout) {
500 Error("CheckSanity", "didn't get TGTableLayoutHints");
501 return;
502 }
503
504 UInt_t right = layout->GetAttachRight();
505 UInt_t left = layout->GetAttachLeft();
506 UInt_t top = layout->GetAttachTop();
507 UInt_t bottom = layout->GetAttachBottom();
508
509 if (left == right) {
510 ++nerrors;
511 Error("CheckSanity", "AttachLeft == AttachRight");
512 }
513 if (left > right) {
514 ++nerrors;
515 Error("CheckSanity", "AttachLeft > AttachRight");
516 }
517 if (left > fNcols-1) {
518 ++nerrors;
519 Error("CheckSanity", "AttachLeft illegal value: %u", left);
520 }
521 if (right < 1 || right > fNcols) {
522 ++nerrors;
523 Error("CheckSanity", "AttachRight illegal value: %u", right);
524 }
525
526 if (top == bottom) {
527 ++nerrors;
528 Error("CheckSanity", "AttachTop == AttachBottom");
529 }
530 if (top > bottom) {
531 ++nerrors;
532 Error("CheckSanity", "AttachTop > AttachBottom");
533 }
534 if (top > fNrows-1) {
535 ++nerrors;
536 Error("CheckSanity", "AttachTop illegal value: %u", top);
537 }
538 if (bottom < 1 || bottom > fNrows) {
539 ++nerrors;
540 Error("CheckSanity", "AttachBottom illegal value: %u", bottom);
541 }
542
543 }
544 if (nerrors) {
545 Error("CheckSanity", "errors in %u x %u table", fNcols, fNrows);
546 }
547}
548
549////////////////////////////////////////////////////////////////////////////////
550/// Make a table layout of all frames in the list.
551
553{
554 CheckSanity();
555
557
559
560 // Do the layout
561 TIter next(fList);
562 TGFrameElement *ptr;
563 UInt_t border_width = fMain->GetBorderWidth();
564 while ((ptr = (TGFrameElement*) next())) {
565 TGTableLayoutHints *layout =
566 dynamic_cast<TGTableLayoutHints*>(ptr->fLayout);
567 if (!layout) {
568 Error("TGTableLayout::Layout", "didn't get TGTableLayoutHints");
569 return;
570 }
571 ULong_t hints = layout->GetLayoutHints();
573
574 UInt_t right = layout->GetAttachRight();
575 UInt_t left = layout->GetAttachLeft();
576 UInt_t top = layout->GetAttachTop();
577 UInt_t bottom = layout->GetAttachBottom();
578
579 // Find location and size of cell in which to fit the child frame.
580 UInt_t col, cell_x = border_width + left*fSep;
581 for (col = 0; col < left; ++col) cell_x += fCol[col].fRealSize;
582
583 UInt_t row, cell_y = border_width + top*fSep;
584 for (row = 0; row < top; ++row) cell_y += fRow[row].fRealSize;
585
586 UInt_t cell_width = (right-left-1)*fSep;
587 for (col=left; col < right; ++col)
588 cell_width += fCol[col].fRealSize;
589
590 UInt_t cell_height = (bottom-top-1)*fSep;
591 for (row=top; row < bottom; ++row)
592 cell_height += fRow[row].fRealSize;
593
594 UInt_t pad_left = layout->GetPadLeft();
595 UInt_t pad_right = layout->GetPadRight();
596 UInt_t pad_bottom = layout->GetPadBottom();
597 UInt_t pad_top = layout->GetPadTop();
598
599 // find size of child frame
600 UInt_t ww,hh;
601 if (hints & kLHintsFillX)
602 ww = cell_width - pad_left - pad_right;
603 else
604 ww = size.fWidth;
605 if (hints & kLHintsFillY)
606 hh = cell_height - pad_top - pad_bottom;
607 else
608 hh = size.fHeight;
609
610 // Find location of child frame
611 UInt_t xx;
612 if (hints & kLHintsFillX) // Fill beats right/center/left hints
613 xx = cell_x + pad_left;
614 else if (hints & kLHintsRight)
615 xx = cell_x + cell_width - pad_right - ww;
616 else if (hints & kLHintsCenterX)
617 xx = cell_x + cell_width/2 - ww/2; // padding?
618 else // defaults to kLHintsLeft
619 xx = cell_x + pad_left;
620
621 UInt_t yy;
622 if (hints & kLHintsFillY) // Fill beats top/center/bottom hings
623 yy = cell_y + pad_top;
624 else if (hints & kLHintsBottom)
625 yy = cell_y + cell_height - pad_bottom - hh;
626 else if (hints & kLHintsCenterY)
627 yy = cell_y + cell_height/2 - hh/2; // padding?
628 else // defaults to kLHintsTop
629 yy = cell_y + pad_top;
630
631 ptr->fFrame->MoveResize(xx,yy,ww,hh);
632 ptr->fFrame->Layout();
633
634 }
635}
636
637////////////////////////////////////////////////////////////////////////////////
638/// Return default dimension of the table layout.
639
641{
642 TGDimension msize = fMain->GetSize();
643 UInt_t options = fMain->GetOptions();
644
645 if ((options & kFixedWidth) && (options & kFixedHeight))
646 return msize;
647
648 Int_t border_width = fMain->GetBorderWidth();
649
650 TGDimension size(2*border_width + (fNcols-1)*fSep,
651 2*border_width + (fNrows-1)*fSep);
652
653 UInt_t col, row;
654 if (fCol)
655 for (col = 0; col < fNcols; ++col) size.fWidth += fCol[col].fDefSize;
656 if (fRow)
657 for (row = 0; row < fNrows; ++row) size.fHeight += fRow[row].fDefSize;
658
659 if (options & kFixedWidth) size.fWidth = msize.fWidth;
660 if (options & kFixedHeight) size.fHeight = msize.fHeight;
661 return size;
662}
663
664// ________________________________________________________________________
665void TGTableLayoutHints::SavePrimitive(std::ostream &out, Option_t * /*= ""*/)
666{
667
668 // Save table layout hints as a C++ statement(s) on output stream out.
669
670 TString hints;
672
673 if (!GetLayoutHints()) return;
674
675 if ((fLayoutHints == kLHintsNormal) && (pad == 0)) return;
676
678 if (hints.Length() == 0) hints = "kLHintsLeft";
679 else hints += " | kLHintsLeft";
680 }
682 if (hints.Length() == 0) hints = "kLHintsCenterX";
683 else hints += " | kLHintsCenterX";
684 }
686 if (hints.Length() == 0) hints = "kLHintsRight";
687 else hints += " | kLHintsRight";
688 }
689 if (fLayoutHints & kLHintsTop) {
690 if (hints.Length() == 0) hints = "kLHintsTop";
691 else hints += " | kLHintsTop";
692 }
694 if (hints.Length() == 0) hints = "kLHintsCenterY";
695 else hints += " | kLHintsCenterY";
696 }
698 if (hints.Length() == 0) hints = "kLHintsBottom";
699 else hints += " | kLHintsBottom";
700 }
702 if (hints.Length() == 0) hints = "kLHintsExpandX";
703 else hints += " | kLHintsExpandX";
704 }
706 if (hints.Length() == 0) hints = "kLHintsExpandY";
707 else hints += " | kLHintsExpandY";
708 }
710 if (hints.Length() == 0) hints = "kLHintsShrinkX";
711 else hints += " | kLHintsShrinkX";
712 }
714 if (hints.Length() == 0) hints = "kLHintsShrinkY";
715 else hints += " | kLHintsShrinkY";
716 }
718 if (hints.Length() == 0) hints = "kLHintsFillX";
719 else hints += " | kLHintsFillX";
720 }
722 if (hints.Length() == 0) hints = "kLHintsFillY";
723 else hints += " | kLHintsFillY";
724 }
725 out << ", new TGTableLayoutHints(" << GetAttachLeft() << "," << GetAttachRight()
726 << "," << GetAttachTop() << "," << GetAttachBottom()
727 << "," << hints;
728
729 if (pad) {
730 out << "," << GetPadLeft() << "," << GetPadRight()
731 << "," << GetPadTop() << "," << GetPadBottom();
732 }
733 out << ")";
734}
735
736// __________________________________________________________________________
737void TGTableLayout::SavePrimitive(std::ostream &out, Option_t * /*= ""*/)
738{
739
740 // Save table layout as a C++ statement(s) on output stream.
741
742 out << " new TGTableLayout(" << fMain->GetName() << "," << fNrows << "," << fNcols;
743
744 if (fSep) {
745 if (fHomogeneous == kTRUE)
746 out << ", kTRUE";
747 else
748 out << ", kFALSE";
749 out << fSep;
750 }
751 out << ")";
752 // hints parameter is not used/saved currently
753
754}
@ kFixedWidth
Definition GuiTypes.h:387
@ kFixedHeight
Definition GuiTypes.h:389
int main()
Definition Prototype.cxx:12
size_t size(const MatrixT &matrix)
retrieve the size of a square matrix
unsigned long ULong_t
Definition RtypesCore.h:55
constexpr Bool_t kFALSE
Definition RtypesCore.h:94
constexpr Bool_t kTRUE
Definition RtypesCore.h:93
const char Option_t
Definition RtypesCore.h:66
#define ClassImp(name)
Definition Rtypes.h:382
@ 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
@ kLHintsFillX
@ kLHintsShrinkX
@ kLHintsShrinkY
@ kLHintsFillY
Option_t Option_t width
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t height
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
TGFrame * fFrame
Definition TGLayout.h:112
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
Int_t GetBorderWidth() const
Definition TGFrame.h:233
virtual UInt_t GetDefaultWidth() const
Definition TGFrame.h:190
virtual UInt_t GetDefaultHeight() const
Definition TGFrame.h:191
TGDimension GetSize() const
Definition TGFrame.h:230
virtual UInt_t GetOptions() const
Definition TGFrame.h:197
UInt_t GetHeight() const
Definition TGFrame.h:225
virtual void Layout()
Definition TGFrame.h:199
UInt_t GetWidth() const
Definition TGFrame.h:224
Int_t GetPadRight() const
Definition TGLayout.h:86
Int_t GetPadBottom() const
Definition TGLayout.h:84
ULong_t fLayoutHints
Definition TGLayout.h:62
ULong_t GetLayoutHints() const
Definition TGLayout.h:82
Int_t GetPadTop() const
Definition TGLayout.h:83
Int_t GetPadLeft() const
Definition TGLayout.h:85
This class describes layout hints used by the TGTableLayout class.
void SavePrimitive(std::ostream &out, Option_t *="") override
Save layout hints as a C++ statement(s) on output stream out.
UInt_t GetAttachLeft() const
UInt_t GetAttachTop() const
UInt_t GetAttachBottom() const
UInt_t GetAttachRight() const
A layout manager, which places child frames in a table arranged in rows and columns,...
Bool_t fHomogeneous
all cols/rows same size
void FindRowColSizesMultiplyAttached()
Checks any children which span multiple col/rows.
~TGTableLayout() override
TGTableLayout constructor.
void FindRowColSizesHomogeneous()
If the table is homogeneous make sure all col/rows are same size as biggest col/row.
void SetRowColSizes()
This gets the new sizes needed to fit the table to the parent frame.
TableData_t * fRow
info about each row
void Layout() override
Make a table layout of all frames in the list.
Int_t fHints
layout hints (currently not used)
static void SetRowColResize(UInt_t real_size, UInt_t nthings, TableData_t *thing, Bool_t homogeneous)
If main frame is bigger or smaller than all children, expand/shrink to fill.
void FindRowColSizesSinglyAttached()
Determine the size of rows/cols needed for singly attached children.
UInt_t fNcols
number of columns
void FindRowColSizesInit()
Initialize values needed to determine the size of rows and columns.
Int_t fSep
interval between frames
void CheckSanity()
Sanity check various values.
UInt_t fNrows
number of rows
TableData_t * fCol
info about each column
TList * fList
list of frames to arrange
void SavePrimitive(std::ostream &out, Option_t *="") override
Save a primitive as a C++ statement(s) on output stream "out".
TGCompositeFrame * fMain
container frame
TGTableLayout(const TGTableLayout &)=delete
TGDimension GetDefaultSize() const override
Return default dimension of the table layout.
void FindRowColSizes()
Find the sizes of rows and columns needed to satisfy children's layout policies.
void SetRowColSizesInit()
Initialize rows/cols.
const char * GetName() const override
Return unique name, used in SavePrimitive methods.
Definition TGWindow.cxx:336
void Reset()
virtual void Error(const char *method, const char *msgfmt,...) const
Issue error message.
Definition TObject.cxx:1005
Basic string class.
Definition TString.h:139
Ssiz_t Length() const
Definition TString.h:417
Short_t Max(Short_t a, Short_t b)
Returns the largest of a and b.
Definition TMathBase.h:250
UInt_t fDefSize
Default size of col/rows.
UInt_t fRealSize
Real size of col/rows (eg, if table resize)