142 for (i = 0; i <
fNrows; ++i)
fRow[i].fDefSize = 0;
143 for (i = 0; i <
fNcols; ++i)
fCol[i].fDefSize = 0;
155 if (ptr->
fState == 0)
continue;
159 Error(
"FindRowColSizesSinglyAttached",
"didn't get TGTableLayoutHints from %s, layout = 0x%zx",
165 fCol[col].fDefSize = std::max(
fCol[col].fDefSize,
172 fRow[row].fDefSize = std::max(
fRow[row].fDefSize,
187 UInt_t max_width = 0, max_height = 0, col, row;
190 for (col = 0; col <
fNcols; ++col)
191 max_width = std::max(max_width,
fCol[col].fDefSize);
193 for (row = 0; row <
fNrows; ++row)
194 max_height = std::max(max_height,
fRow[row].fDefSize);
197 for (col = 0; col <
fNcols; ++col)
fCol[col].fDefSize = max_width;
198 for (row = 0; row <
fNrows; ++row)
fRow[row].fDefSize = max_height;
210 if (ptr->
fState == 0)
continue;
214 Error(
"FindRowColSizesMultiplyAttached",
"didn't get TGTableLayoutHints");
219 if (left != right-1) {
221 for (col = left; col < right; ++col) width +=
fCol[col].fDefSize;
227 if (width < child_width) {
228 width = child_width - width;
229 for (col = left; col < right; ++col) {
230 UInt_t extra = width / (right - col);
231 fCol[col].fDefSize += extra;
238 if (top != bottom-1) {
240 for (row = top; row < bottom; ++row) height +=
fRow[row].fDefSize;
246 if (height < child_height) {
247 height = child_height - height;
248 for (row = top; row < bottom; ++row) {
249 UInt_t extra = height / (bottom - row);
250 fRow[row].fDefSize += extra;
267 UInt_t ind, nshrink=0, nexpand=0, cur_size=0;
269 for (ind = 0; ind < nthings; ++ind)
270 cur_size += thing[ind].fDefSize;
272 if (cur_size < real_size) {
273 for (ind = 0; ind < nthings; ++ind)
274 if (thing[ind].fExpand) { ++ nexpand;
break; }
277 for (ind = 0; ind < nthings; ++ ind) {
279 thing[ind].
fRealSize = std::max(1U, extra);
284 if (cur_size > real_size) {
285 for (ind = 0; ind < nthings; ++ind)
286 if (thing[ind].fShrink) { ++ nshrink;
break; }
289 for (ind = 0; ind < nthings; ++ ind) {
291 thing[ind].
fRealSize = std::max(1U, extra);
298 for (ind = 0; ind < nthings; ++ind) {
300 if (thing[ind].fExpand) ++ nexpand;
301 if (thing[ind].fShrink) ++ nshrink;
305 if ((
size < real_size) && (nexpand >= 1)) {
307 for (ind = 0; ind < nthings; ++ind) {
308 if (thing[ind].fExpand) {
318 if (
size > real_size) {
319 UInt_t total_nshrink = nshrink;
321 while (total_nshrink > 0 && extra > 0) {
322 nshrink = total_nshrink;
323 for (ind = 0; ind < nthings; ++ind)
324 if (thing[ind].fShrink) {
326 thing[ind].
fRealSize = std::max(1U,thing[ind].fRealSize - extra / nshrink);
329 if (thing[ind].fRealSize < 2) {
361 for (col = 0; col <
fNcols; ++col) {
362 fCol[col].fRealSize =
fCol[col].fDefSize;
370 for (row = 0; row <
fNrows; ++row) {
371 fRow[row].fRealSize =
fRow[row].fDefSize;
386 Error(
"SetRowColSizesInit",
"didn't get TGTableLayoutHints");
415 Error(
"SetRowColSizesInit",
"didn't get TGTableLayoutHints");
423 if (left != right - 1) {
424 for (col = left; col < right; ++col)
fCol[col].fEmpty =
kFALSE;
427 for (col = left; col < right; ++col)
428 if (
fCol[col].fExpand) { has_expand =
kTRUE;
break; }
430 for (col = left; col < right; ++col)
434 for (col = left; col < right; ++col)
435 if (!
fCol[col].fShrink) { has_shrink =
kFALSE;
break;}
437 for (col = left; col < right; ++col)
445 if (top != bottom - 1) {
446 for (row = top; row < bottom; ++row)
fRow[row].fEmpty =
kFALSE;
449 for (row = top; row < bottom; ++row)
450 if (
fRow[row].fExpand) { has_expand =
kTRUE;
break; }
452 for (row = top; row < bottom; ++row)
456 for (row = top; row < bottom; ++row)
457 if (!
fRow[row].fShrink) { has_shrink =
kFALSE;
break;}
459 for (row = top; row < bottom; ++row)
466 for (col = 0; col <
fNcols; ++col) {
467 if (
fCol[col].fEmpty) {
475 for (row = 0; row <
fNrows; ++row) {
476 if (
fRow[row].fEmpty) {
498 Error(
"CheckSanity",
"didn't get TGTableLayoutHints");
509 Error(
"CheckSanity",
"AttachLeft == AttachRight");
513 Error(
"CheckSanity",
"AttachLeft > AttachRight");
517 Error(
"CheckSanity",
"AttachLeft illegal value: %u", left);
519 if (right < 1 || right >
fNcols) {
521 Error(
"CheckSanity",
"AttachRight illegal value: %u", right);
526 Error(
"CheckSanity",
"AttachTop == AttachBottom");
530 Error(
"CheckSanity",
"AttachTop > AttachBottom");
534 Error(
"CheckSanity",
"AttachTop illegal value: %u", top);
536 if (bottom < 1 || bottom >
fNrows) {
538 Error(
"CheckSanity",
"AttachBottom illegal value: %u", bottom);
566 Error(
"TGTableLayout::Layout",
"didn't get TGTableLayoutHints");
578 UInt_t col, cell_x = border_width + left*
fSep;
579 for (col = 0; col < left; ++col) cell_x +=
fCol[col].fRealSize;
582 for (row = 0; row < top; ++row) cell_y +=
fRow[row].fRealSize;
585 for (col=left; col < right; ++col)
586 cell_width +=
fCol[col].fRealSize;
589 for (row=top; row < bottom; ++row)
590 cell_height +=
fRow[row].fRealSize;
600 ww = cell_width - pad_left - pad_right;
604 hh = cell_height - pad_top - pad_bottom;
611 xx = cell_x + pad_left;
613 xx = cell_x + cell_width - pad_right - ww;
615 xx = cell_x + cell_width/2 - ww/2;
617 xx = cell_x + pad_left;
621 yy = cell_y + pad_top;
623 yy = cell_y + cell_height - pad_bottom - hh;
625 yy = cell_y + cell_height/2 - hh/2;
627 yy = cell_y + pad_top;
653 for (col = 0; col <
fNcols; ++col)
size.fWidth +=
fCol[col].fDefSize;
655 for (row = 0; row <
fNrows; ++row)
size.fHeight +=
fRow[row].fDefSize;
677 auto add = [
this, &hints](
UInt_t mask,
const char *
name) {
712 out <<
" new TGTableLayout(" <<
fMain->GetName() <<
"," <<
fNrows <<
"," <<
fNcols;
size_t size(const MatrixT &matrix)
retrieve the size of a square matrix
int Int_t
Signed integer 4 bytes (int).
unsigned int UInt_t
Unsigned integer 4 bytes (unsigned int).
unsigned long ULong_t
Unsigned long integer 4 bytes (unsigned long). Size depends on architecture.
bool Bool_t
Boolean (0=false, 1=true) (bool).
const char Option_t
Option string (const char).
The base class for composite widgets (menu bars, list boxes, etc.).
virtual TGDimension GetDefaultSize() const
std::cout << fWidth << "x" << fHeight << std::endl;
void MoveResize(Int_t x, Int_t y, UInt_t w=0, UInt_t h=0) override
Move and/or resize the frame.
virtual UInt_t GetDefaultWidth() const
virtual UInt_t GetDefaultHeight() const
Int_t GetPadRight() const
Int_t GetPadBottom() const
ULong_t GetLayoutHints() const
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
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.
virtual void Error(const char *method, const char *msgfmt,...) const
Issue error message.
TString & Append(const char *cs)
int main(int argc, char **argv)
UInt_t fDefSize
Default size of col/rows.
UInt_t fRealSize
Real size of col/rows (eg, if table resize).