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