00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053 #include "TGLayout.h"
00054 #include "TGFrame.h"
00055 #include "TList.h"
00056 #include "Riostream.h"
00057
00058
00059 ClassImp(TGLayoutHints)
00060 ClassImp(TGLayoutManager)
00061 ClassImp(TGVerticalLayout)
00062 ClassImp(TGHorizontalLayout)
00063 ClassImp(TGRowLayout)
00064 ClassImp(TGColumnLayout)
00065 ClassImp(TGMatrixLayout)
00066 ClassImp(TGTileLayout)
00067 ClassImp(TGListLayout)
00068 ClassImp(TGListDetailsLayout)
00069
00070
00071
00072 TGFrameElement::TGFrameElement(TGFrame *f, TGLayoutHints *l)
00073 {
00074
00075
00076 fLayout = 0;
00077 fFrame = f;
00078 if (f) f->SetFrameElement(this);
00079
00080 if (l) {
00081 l->AddReference();
00082 fLayout = l;
00083 l->fPrev = l->fFE;
00084 l->fFE = this;
00085 }
00086 fState = 1;
00087 }
00088
00089
00090 TGFrameElement::~TGFrameElement()
00091 {
00092
00093
00094 }
00095
00096
00097 void TGFrameElement::Print(Option_t *option) const
00098 {
00099
00100
00101 TObject::Print(option);
00102
00103 cout << "\t";
00104 if (fFrame) {
00105 cout << fFrame->ClassName() << "::" << fFrame->GetName();
00106 }
00107 if (fLayout) {
00108 fLayout->Print(option);
00109 }
00110 cout << endl;
00111 }
00112
00113
00114 TGLayoutHints::TGLayoutHints(const TGLayoutHints &lh) : TObject(lh), TRefCnt(lh)
00115 {
00116
00117
00118 fPadleft = lh.fPadleft; fPadright = lh.fPadright;
00119 fPadtop = lh.fPadtop; fPadbottom = lh.fPadbottom;
00120 fLayoutHints = lh.fLayoutHints;
00121 SetRefCount(0);
00122 fFE = lh.fFE; fPrev = lh.fPrev;
00123 }
00124
00125
00126 TGLayoutHints::~TGLayoutHints()
00127 {
00128
00129
00130 }
00131
00132
00133 void TGLayoutHints::UpdateFrameElements(TGLayoutHints *l)
00134 {
00135
00136
00137 if (fFE) fFE->fLayout = l;
00138 else return;
00139
00140 TGFrameElement *p = fPrev;
00141
00142 while (p && p->fLayout) {
00143 p->fLayout = l;
00144 p = p->fLayout->fPrev;
00145 }
00146 }
00147
00148
00149 void TGLayoutHints::Print(Option_t *) const
00150 {
00151
00152
00153 Bool_t bor = kFALSE;
00154
00155 if (fLayoutHints & kLHintsLeft) {
00156 cout << "kLHintsLeft";
00157 bor = kTRUE;
00158 }
00159 if (fLayoutHints & kLHintsCenterX) {
00160 if (bor) cout << " | ";
00161 cout << "kLHintsCenterX";
00162 bor = kTRUE;
00163 }
00164 if (fLayoutHints & kLHintsRight) {
00165 if (bor) cout << " | ";
00166 cout << "kLHintsRight";
00167 bor = kTRUE;
00168 }
00169 if (fLayoutHints & kLHintsTop) {
00170 if (bor) cout << " | ";
00171 cout << "kLHintsTop";
00172 bor = kTRUE;
00173 }
00174 if (fLayoutHints & kLHintsCenterY) {
00175 if (bor) cout << " | ";
00176 cout << "kLHintsCenterY";
00177 bor = kTRUE;
00178 }
00179 if (fLayoutHints & kLHintsBottom) {
00180 if (bor) cout << " | ";
00181 cout << "kLHintsBottom";
00182 bor = kTRUE;
00183 }
00184 if (fLayoutHints & kLHintsExpandX) {
00185 if (bor) cout << " | ";
00186 cout << "kLHintsExpandX";
00187 bor = kTRUE;
00188 }
00189 if (fLayoutHints & kLHintsExpandY) {
00190 if (bor) cout << " | ";
00191 cout << "kLHintsExpandY";
00192 bor = kTRUE;
00193 }
00194 if (fLayoutHints == kLHintsNoHints) {
00195 if (bor) cout << " | ";
00196 cout << "kLHintsNoHints";
00197 }
00198 cout << ", fPadtop=" << fPadtop;
00199 cout << ", fPadbottom=" << fPadbottom;
00200 cout << ", fPadleft=" << fPadleft;
00201 cout << ", fPadright=" << fPadright;
00202 cout << endl;
00203 }
00204
00205
00206 TGVerticalLayout::TGVerticalLayout(TGCompositeFrame *main)
00207 {
00208
00209
00210 fMain = main;
00211 fList = fMain->GetList();
00212 }
00213
00214
00215 void TGVerticalLayout::Layout()
00216 {
00217
00218
00219 TGFrameElement *ptr;
00220 TGLayoutHints *layout;
00221 Int_t nb_expand = 0;
00222 Int_t top, bottom;
00223 ULong_t hints;
00224 UInt_t extra_space = 0;
00225 Int_t exp = 0;
00226 Int_t exp_max = 0;
00227 Int_t remain;
00228 Int_t x = 0, y = 0;
00229 Int_t bw = fMain->GetBorderWidth();
00230 TGDimension size(0,0), csize(0,0);
00231 TGDimension msize = fMain->GetSize();
00232 UInt_t pad_left, pad_top, pad_right, pad_bottom;
00233 Int_t size_expand=0, esize_expand=0, rem_expand=0, tmp_expand = 0;
00234
00235 if (!fList) return;
00236
00237 fModified = kFALSE;
00238
00239 bottom = msize.fHeight - (top = bw);
00240 remain = msize.fHeight - (bw << 1);
00241
00242 TIter next(fList);
00243 while ((ptr = (TGFrameElement *) next())) {
00244 if (ptr->fState & kIsVisible) {
00245 layout = ptr->fLayout;
00246 size = ptr->fFrame->GetDefaultSize();
00247 size.fHeight += layout->GetPadTop() + layout->GetPadBottom();
00248 hints = layout->GetLayoutHints();
00249 if ((hints & kLHintsExpandY) || (hints & kLHintsCenterY)) {
00250 nb_expand++;
00251 exp += size.fHeight;
00252 if (hints & kLHintsExpandY) exp_max = 0;
00253 else exp_max = TMath::Max(exp_max, (Int_t)size.fHeight);
00254 } else {
00255 remain -= size.fHeight;
00256 if (remain < 0)
00257 remain = 0;
00258 }
00259 }
00260 }
00261
00262 if (nb_expand) {
00263 size_expand = remain/nb_expand;
00264
00265 if (size_expand < exp_max)
00266 esize_expand = (remain - exp)/nb_expand;
00267 rem_expand = remain % nb_expand;
00268 }
00269
00270 next.Reset();
00271 while ((ptr = (TGFrameElement *) next())) {
00272 if (ptr->fState & kIsVisible) {
00273 hints = (layout = ptr->fLayout)->GetLayoutHints();
00274 csize = ptr->fFrame->GetDefaultSize();
00275 pad_left = layout->GetPadLeft();
00276 pad_top = layout->GetPadTop();
00277 pad_right = layout->GetPadRight();
00278 pad_bottom = layout->GetPadBottom();
00279
00280 if (hints & kLHintsRight) {
00281 x = msize.fWidth - bw - csize.fWidth - pad_right;
00282 } else if (hints & kLHintsCenterX) {
00283 x = (msize.fWidth - (bw << 1) - csize.fWidth) >> 1;
00284 } else {
00285 x = pad_left + bw;
00286 }
00287
00288 if (hints & kLHintsExpandX) {
00289 size.fWidth = msize.fWidth - (bw << 1) - pad_left - pad_right;
00290 x = pad_left + bw;
00291 } else {
00292 size.fWidth = csize.fWidth;
00293 }
00294
00295 if (hints & kLHintsExpandY) {
00296 if (size_expand >= exp_max)
00297 size.fHeight = size_expand - pad_top - pad_bottom;
00298 else
00299 size.fHeight = csize.fHeight + esize_expand;
00300
00301 tmp_expand += rem_expand;
00302 if (tmp_expand >= nb_expand) {
00303 size.fHeight++;
00304 tmp_expand -= nb_expand;
00305 }
00306 } else {
00307 size.fHeight = csize.fHeight;
00308 if (hints & kLHintsCenterY) {
00309 if (size_expand >= exp_max) {
00310 extra_space = (size_expand - pad_top - pad_bottom - size.fHeight) >> 1;
00311 } else {
00312 extra_space = esize_expand >> 1;
00313 }
00314 y += extra_space;
00315 top += extra_space;
00316 }
00317 }
00318
00319 if (hints & kLHintsBottom) {
00320 y = bottom - size.fHeight - pad_bottom;
00321 bottom -= size.fHeight + pad_top + pad_bottom;
00322 } else {
00323 y = top + pad_top;
00324 top += size.fHeight + pad_top + pad_bottom;
00325 }
00326
00327 if (hints & kLHintsCenterY)
00328 top += extra_space;
00329
00330 if (size.fWidth > 32768)
00331 size.fWidth = 1;
00332 if (size.fHeight > 32768)
00333 size.fHeight = 1;
00334 ptr->fFrame->MoveResize(x, y, size.fWidth, size.fHeight);
00335
00336 fModified = fModified || (ptr->fFrame->GetX() != x) ||
00337 (ptr->fFrame->GetY() != y) ||
00338 (ptr->fFrame->GetWidth() != size.fWidth) ||
00339 (ptr->fFrame->GetHeight() != size.fHeight);
00340 }
00341 }
00342 }
00343
00344
00345 TGDimension TGVerticalLayout::GetDefaultSize() const
00346 {
00347
00348
00349 TGFrameElement *ptr;
00350 TGDimension size(0,0), msize = fMain->GetSize(), csize;
00351 UInt_t options = fMain->GetOptions();
00352
00353 if ((options & kFixedWidth) && (options & kFixedHeight))
00354 return msize;
00355
00356 TIter next(fList);
00357 while ((ptr = (TGFrameElement *) next())) {
00358 if (ptr->fState & kIsVisible) {
00359 csize = ptr->fFrame->GetDefaultSize();
00360 size.fWidth = TMath::Max(size.fWidth, csize.fWidth + ptr->fLayout->GetPadLeft() +
00361 ptr->fLayout->GetPadRight());
00362 size.fHeight += csize.fHeight + ptr->fLayout->GetPadTop() +
00363 ptr->fLayout->GetPadBottom();
00364 }
00365 }
00366
00367 size.fWidth += fMain->GetBorderWidth() << 1;
00368 size.fHeight += fMain->GetBorderWidth() << 1;
00369
00370 if (options & kFixedWidth) size.fWidth = msize.fWidth;
00371 if (options & kFixedHeight) size.fHeight = msize.fHeight;
00372
00373 return size;
00374 }
00375
00376
00377 void TGHorizontalLayout::Layout()
00378 {
00379
00380
00381 TGFrameElement *ptr;
00382 TGLayoutHints *layout;
00383 Int_t nb_expand = 0;
00384 Int_t left, right;
00385 ULong_t hints;
00386 UInt_t extra_space = 0;
00387 Int_t exp = 0;
00388 Int_t exp_max = 0;
00389 Int_t remain;
00390 Int_t x = 0, y = 0;
00391 Int_t bw = fMain->GetBorderWidth();
00392 TGDimension size, csize;
00393 TGDimension msize = fMain->GetSize();
00394 UInt_t pad_left, pad_top, pad_right, pad_bottom;
00395 Int_t size_expand=0, esize_expand=0, rem_expand=0, tmp_expand = 0;
00396
00397 if (!fList) return;
00398
00399 fModified = kFALSE;
00400 right = msize.fWidth - (left = bw);
00401 remain = msize.fWidth - (bw << 1);
00402
00403 TIter next(fList);
00404 while ((ptr = (TGFrameElement *) next())) {
00405 if (ptr->fState & kIsVisible) {
00406 layout = ptr->fLayout;
00407 size = ptr->fFrame->GetDefaultSize();
00408 size.fWidth += layout->GetPadLeft() + layout->GetPadRight();
00409 hints = layout->GetLayoutHints();
00410 if ((hints & kLHintsExpandX) || (hints & kLHintsCenterX)) {
00411 nb_expand++;
00412 exp += size.fWidth;
00413 if (hints & kLHintsExpandX) exp_max = 0;
00414 else exp_max = TMath::Max(exp_max, (Int_t)size.fWidth);
00415 } else {
00416 remain -= size.fWidth;
00417 if (remain < 0)
00418 remain = 0;
00419 }
00420 }
00421 }
00422 if (nb_expand) {
00423 size_expand = remain/nb_expand;
00424
00425 if (size_expand < exp_max) {
00426 esize_expand = (remain - exp)/nb_expand;
00427 }
00428 rem_expand = remain % nb_expand;
00429 }
00430
00431 next.Reset();
00432 while ((ptr = (TGFrameElement *) next())) {
00433 if (ptr->fState & kIsVisible) {
00434 hints = (layout = ptr->fLayout)->GetLayoutHints();
00435 csize = ptr->fFrame->GetDefaultSize();
00436 pad_left = layout->GetPadLeft();
00437 pad_top = layout->GetPadTop();
00438 pad_right = layout->GetPadRight();
00439 pad_bottom = layout->GetPadBottom();
00440
00441 if (hints & kLHintsBottom) {
00442 y = msize.fHeight - bw - csize.fHeight - pad_bottom;
00443 } else if (hints & kLHintsCenterY) {
00444 y = (msize.fHeight - (bw << 1) - csize.fHeight) >> 1;
00445 } else {
00446 y = pad_top + bw;
00447 }
00448
00449 if (hints & kLHintsExpandY) {
00450 size.fHeight = msize.fHeight - (bw << 1) - pad_top - pad_bottom;
00451 y = pad_top + bw;
00452 } else {
00453 size.fHeight = csize.fHeight;
00454 }
00455
00456 if (hints & kLHintsExpandX) {
00457 if (size_expand >= exp_max)
00458 size.fWidth = size_expand - pad_left - pad_right;
00459 else
00460 size.fWidth = csize.fWidth + esize_expand;
00461
00462 tmp_expand += rem_expand;
00463
00464 if (tmp_expand >= nb_expand) {
00465 size.fWidth++;
00466 tmp_expand -= nb_expand;
00467 }
00468 } else {
00469 size.fWidth = csize.fWidth;
00470 if (hints & kLHintsCenterX) {
00471 if (size_expand >= exp_max) {
00472 extra_space = (size_expand - pad_left - pad_right - size.fWidth)>> 1;
00473 } else {
00474 extra_space = esize_expand >> 1;
00475 }
00476 x += extra_space;
00477 left += extra_space;
00478 }
00479 }
00480
00481 if (hints & kLHintsRight) {
00482 x = right - size.fWidth - pad_right;
00483 right -= size.fWidth + pad_left + pad_right;
00484 } else {
00485 x = left + pad_left;
00486 left += size.fWidth + pad_left + pad_right;
00487 }
00488
00489 if (hints & kLHintsCenterX)
00490 left += extra_space;
00491
00492 ptr->fFrame->MoveResize(x, y, size.fWidth, size.fHeight);
00493
00494 fModified = fModified || (ptr->fFrame->GetX() != x) ||
00495 (ptr->fFrame->GetY() != y) ||
00496 (ptr->fFrame->GetWidth() != size.fWidth) ||
00497 (ptr->fFrame->GetHeight() != size.fHeight);
00498 }
00499 }
00500 }
00501
00502
00503 TGDimension TGHorizontalLayout::GetDefaultSize() const
00504 {
00505
00506
00507 TGFrameElement *ptr;
00508 TGDimension size(0,0), msize = fMain->GetSize(), csize;
00509 UInt_t options = fMain->GetOptions();
00510
00511 if ((options & kFixedWidth) && (options & kFixedHeight))
00512 return msize;
00513
00514 TIter next(fList);
00515 while ((ptr = (TGFrameElement *) next())) {
00516 if (ptr->fState & kIsVisible) {
00517 csize = ptr->fFrame->GetDefaultSize();
00518 size.fWidth += csize.fWidth + ptr->fLayout->GetPadLeft() +
00519 ptr->fLayout->GetPadRight();
00520
00521 size.fHeight = TMath::Max(size.fHeight, csize.fHeight + ptr->fLayout->GetPadTop() +
00522 ptr->fLayout->GetPadBottom());
00523 }
00524 }
00525 size.fWidth += fMain->GetBorderWidth() << 1;
00526 size.fHeight += fMain->GetBorderWidth() << 1;
00527
00528 if (options & kFixedWidth) size.fWidth = msize.fWidth;
00529 if (options & kFixedHeight) size.fHeight = msize.fHeight;
00530
00531 return size;
00532 }
00533
00534
00535 void TGRowLayout::Layout()
00536 {
00537
00538
00539 TGFrameElement *ptr;
00540 TGDimension size;
00541 Int_t bw = fMain->GetBorderWidth();
00542 Int_t x = bw, y = bw;
00543 fModified = kFALSE;
00544
00545 TIter next(fList);
00546 while ((ptr = (TGFrameElement *) next())) {
00547 if (ptr->fState & kIsVisible) {
00548 size = ptr->fFrame->GetDefaultSize();
00549 ptr->fFrame->Move(x, y);
00550
00551 fModified = fModified || (ptr->fFrame->GetX() != x) ||
00552 (ptr->fFrame->GetY() != y);
00553
00554 ptr->fFrame->Layout();
00555 x += size.fWidth + fSep;
00556 }
00557 }
00558 }
00559
00560
00561 TGDimension TGRowLayout::GetDefaultSize() const
00562 {
00563
00564
00565 TGFrameElement *ptr;
00566 TGDimension size(0,0), dsize, msize = fMain->GetSize();
00567 UInt_t options = fMain->GetOptions();
00568
00569 if ((options & kFixedHeight) && (options & kFixedWidth))
00570 return msize;
00571
00572 TIter next(fList);
00573 while ((ptr = (TGFrameElement *) next())) {
00574 if (ptr->fState & kIsVisible) {
00575 dsize = ptr->fFrame->GetDefaultSize();
00576 size.fHeight = TMath::Max(size.fHeight, dsize.fHeight);
00577 size.fWidth += dsize.fWidth + fSep;
00578 }
00579 }
00580
00581 size.fHeight += fMain->GetBorderWidth() << 1;
00582 size.fWidth += fMain->GetBorderWidth() << 1;
00583 size.fWidth -= fSep;
00584
00585 if (options & kFixedHeight) size.fHeight = msize.fHeight;
00586 if (options & kFixedWidth) size.fWidth = msize.fWidth;
00587
00588 return size;
00589 }
00590
00591
00592 void TGColumnLayout::Layout()
00593 {
00594
00595
00596 TGFrameElement *ptr;
00597 TGDimension size;
00598 Int_t bw = fMain->GetBorderWidth();
00599 Int_t x = bw, y = bw;
00600 fModified = kFALSE;
00601
00602 TIter next(fList);
00603 while ((ptr = (TGFrameElement *) next())) {
00604 if (ptr->fState & kIsVisible) {
00605 size = ptr->fFrame->GetDefaultSize();
00606 ptr->fFrame->Move(x, y);
00607 fModified = fModified || (ptr->fFrame->GetX() != x) ||
00608 (ptr->fFrame->GetY() != y);
00609 ptr->fFrame->Layout();
00610 y += size.fHeight + fSep;
00611 }
00612 }
00613 }
00614
00615
00616 TGDimension TGColumnLayout::GetDefaultSize() const
00617 {
00618
00619
00620 TGFrameElement *ptr;
00621 TGDimension size(0,0), dsize, msize = fMain->GetSize();
00622 UInt_t options = fMain->GetOptions();
00623
00624 if (options & kFixedHeight && options & kFixedWidth)
00625 return msize;
00626
00627 TIter next(fList);
00628 while ((ptr = (TGFrameElement *) next())) {
00629 if (ptr->fState & kIsVisible) {
00630 dsize = ptr->fFrame->GetDefaultSize();
00631 size.fHeight += dsize.fHeight + fSep;
00632 size.fWidth = TMath::Max(size.fWidth, dsize.fWidth);
00633 }
00634 }
00635
00636 size.fHeight += fMain->GetBorderWidth() << 1;
00637 size.fHeight -= fSep;
00638 size.fWidth += fMain->GetBorderWidth() << 1;
00639
00640 if (options & kFixedHeight) size.fHeight = msize.fHeight;
00641 if (options & kFixedWidth) size.fWidth = msize.fWidth;
00642
00643 return size;
00644 }
00645
00646
00647 TGMatrixLayout::TGMatrixLayout(TGCompositeFrame *main, UInt_t r, UInt_t c,
00648 Int_t s, Int_t h)
00649 {
00650
00651
00652 fMain = main;
00653 fList = fMain->GetList();
00654 fSep = s;
00655 fHints = h;
00656 fRows = r;
00657 fColumns = c;
00658 }
00659
00660
00661 void TGMatrixLayout::Layout()
00662 {
00663
00664
00665 TGFrameElement *ptr;
00666 TGDimension csize, maxsize(0,0);
00667 Int_t bw = fMain->GetBorderWidth();
00668 Int_t x = fSep, y = fSep + bw;
00669 UInt_t rowcount = fRows, colcount = fColumns;
00670 fModified = kFALSE;
00671
00672 TIter next(fList);
00673 while ((ptr = (TGFrameElement *) next())) {
00674 csize = ptr->fFrame->GetDefaultSize();
00675 maxsize.fWidth = TMath::Max(maxsize.fWidth, csize.fWidth);
00676 maxsize.fHeight = TMath::Max(maxsize.fHeight, csize.fHeight);
00677 }
00678
00679 next.Reset();
00680 while ((ptr = (TGFrameElement *) next())) {
00681 ptr->fFrame->Move(x, y);
00682 fModified = fModified || (ptr->fFrame->GetX() != x) ||
00683 (ptr->fFrame->GetY() != y);
00684
00685 ptr->fFrame->Layout();
00686
00687 if (fColumns == 0) {
00688 y += maxsize.fHeight + fSep;
00689 rowcount--;
00690 if (rowcount <= 0) {
00691 rowcount = fRows;
00692 y = fSep + bw; x += maxsize.fWidth + fSep;
00693 }
00694 } else if (fRows == 0) {
00695 x += maxsize.fWidth + fSep;
00696 colcount--;
00697 if (colcount <= 0) {
00698 colcount = fColumns;
00699 x = fSep; y += maxsize.fHeight + fSep;
00700 }
00701 } else {
00702 x += maxsize.fWidth + fSep;
00703 colcount--;
00704 if (colcount <= 0) {
00705 rowcount--;
00706 if (rowcount <= 0) return;
00707 else {
00708 colcount = fColumns;
00709 x = fSep; y += maxsize.fHeight + fSep;
00710 }
00711 }
00712 }
00713 }
00714 }
00715
00716
00717 TGDimension TGMatrixLayout::GetDefaultSize() const
00718 {
00719
00720
00721 TGFrameElement *ptr;
00722 TGDimension size, csize, maxsize(0,0);
00723 Int_t count = 0;
00724 Int_t bw = fMain->GetBorderWidth();
00725
00726 TIter next(fList);
00727 while ((ptr = (TGFrameElement *) next())) {
00728 count++;
00729 csize = ptr->fFrame->GetDefaultSize();
00730 maxsize.fWidth = TMath::Max(maxsize.fWidth, csize.fWidth);
00731 maxsize.fHeight = TMath::Max(maxsize.fHeight, csize.fHeight);
00732 }
00733
00734 if (fRows == 0) {
00735 Int_t rows = (count % fColumns) ? (count / fColumns + 1) : (count / fColumns);
00736 size.fWidth = fColumns * (maxsize.fWidth + fSep) + fSep;
00737 size.fHeight = rows * (maxsize.fHeight + fSep) + fSep + bw;
00738 } else if (fColumns == 0) {
00739 Int_t cols = (count % fRows) ? (count / fRows + 1) : (count / fRows);
00740 size.fWidth = cols * (maxsize.fWidth + fSep) + fSep;
00741 size.fHeight = fRows * (maxsize.fHeight + fSep) + fSep + bw;
00742 } else {
00743 size.fWidth = fColumns * (maxsize.fWidth + fSep) + fSep;
00744 size.fHeight = fRows * (maxsize.fHeight + fSep) + fSep + bw;
00745 }
00746 return size;
00747 }
00748
00749
00750 TGTileLayout::TGTileLayout(TGCompositeFrame *main, Int_t sep)
00751 {
00752
00753
00754 fMain = main;
00755 fSep = sep;
00756 fList = fMain->GetList();
00757 fModified = kTRUE;
00758 }
00759
00760
00761 void TGTileLayout::Layout()
00762 {
00763
00764
00765 TGFrameElement *ptr;
00766 Int_t x, y, xw, yw;
00767 UInt_t max_width;
00768 ULong_t hints;
00769 TGDimension csize, max_osize(0,0), msize = fMain->GetSize();
00770 fModified = kFALSE;
00771
00772 TIter next(fList);
00773 while ((ptr = (TGFrameElement *) next())) {
00774 csize = ptr->fFrame->GetDefaultSize();
00775 max_osize.fWidth = TMath::Max(max_osize.fWidth, csize.fWidth);
00776 max_osize.fHeight = TMath::Max(max_osize.fHeight, csize.fHeight);
00777 }
00778
00779 max_width = TMath::Max(msize.fWidth, max_osize.fWidth + (fSep << 1));
00780 x = fSep; y = fSep << 1;
00781
00782 next.Reset();
00783 while ((ptr = (TGFrameElement *) next())) {
00784 hints = ptr->fLayout->GetLayoutHints();
00785 csize = ptr->fFrame->GetDefaultSize();
00786
00787 if (hints & kLHintsCenterX)
00788 xw = x + (Int_t)((max_osize.fWidth - csize.fWidth) >> 1);
00789 else if (hints & kLHintsRight)
00790 xw = x + (Int_t)max_osize.fWidth - (Int_t)csize.fWidth;
00791 else
00792 xw = x;
00793
00794 if (hints & kLHintsCenterY)
00795 yw = y + (Int_t)((max_osize.fHeight - csize.fHeight) >> 1);
00796 else if (hints & kLHintsBottom)
00797 yw = y + (Int_t)max_osize.fHeight - (Int_t)csize.fHeight;
00798 else
00799 yw = y;
00800
00801 fModified = fModified || (ptr->fFrame->GetX() != xw) ||
00802 (ptr->fFrame->GetY() != yw);
00803 ptr->fFrame->Move(xw, yw);
00804 x += (Int_t)max_osize.fWidth + fSep;
00805
00806 if (x + max_osize.fWidth > max_width) {
00807 x = fSep;
00808 y += (Int_t)max_osize.fHeight + fSep + (fSep >> 1);
00809 }
00810 }
00811 }
00812
00813
00814 TGDimension TGTileLayout::GetDefaultSize() const
00815 {
00816
00817
00818 TGFrameElement *ptr;
00819 Int_t x, y;
00820 TGDimension max_size, max_osize(0,0), msize = fMain->GetSize();
00821
00822 TIter next(fList);
00823 while ((ptr = (TGFrameElement *) next())) {
00824 max_size = ptr->fFrame->GetDefaultSize();
00825 max_osize.fWidth = TMath::Max(max_osize.fWidth, max_size.fWidth);
00826 max_osize.fHeight = TMath::Max(max_osize.fHeight, max_size.fHeight);
00827 }
00828
00829 max_size.fWidth = TMath::Max(msize.fWidth, max_osize.fWidth + (fSep << 1));
00830
00831 x = fSep; y = fSep << 1;
00832
00833 next.Reset();
00834 while ((ptr = (TGFrameElement *) next())) {
00835 x += max_osize.fWidth + fSep;
00836 if (x + max_osize.fWidth > max_size.fWidth) {
00837 x = fSep;
00838 y += (Int_t)max_osize.fHeight + fSep + (fSep >> 1);
00839 }
00840 }
00841 if (x != fSep) y += max_osize.fHeight + fSep;
00842 max_size.fHeight = TMath::Max(y, (Int_t)msize.fHeight);
00843
00844 return max_size;
00845 }
00846
00847
00848 void TGListLayout::Layout()
00849 {
00850
00851
00852 TGFrameElement *ptr;
00853 Int_t x, y, xw, yw;
00854 UInt_t max_height;
00855 ULong_t hints;
00856 TGDimension csize, max_osize(0,0), msize = fMain->GetSize();
00857 fModified = kFALSE;
00858
00859 TIter next(fList);
00860 while ((ptr = (TGFrameElement *) next())) {
00861 csize = ptr->fFrame->GetDefaultSize();
00862 max_osize.fWidth = TMath::Max(max_osize.fWidth, csize.fWidth);
00863 max_osize.fHeight = TMath::Max(max_osize.fHeight, csize.fHeight);
00864 }
00865
00866 max_height = TMath::Max(msize.fHeight, max_osize.fHeight + (fSep << 1));
00867
00868 x = fSep; y = fSep << 1;
00869
00870 next.Reset();
00871 while ((ptr = (TGFrameElement *) next())) {
00872
00873 hints = ptr->fLayout->GetLayoutHints();
00874 csize = ptr->fFrame->GetDefaultSize();
00875
00876 if (hints & kLHintsCenterX)
00877 xw = x + (Int_t)((max_osize.fWidth - csize.fWidth) >> 1);
00878 else if (hints & kLHintsRight)
00879 xw = x + (Int_t)max_osize.fWidth - (Int_t)csize.fWidth;
00880 else
00881 xw = x;
00882
00883 if (hints & kLHintsCenterY)
00884 yw = y + (Int_t)((max_osize.fHeight - csize.fHeight) >> 1);
00885 else if (hints & kLHintsBottom)
00886 yw = y + (Int_t)max_osize.fHeight - (Int_t)csize.fHeight;
00887 else
00888 yw = y;
00889
00890 fModified = fModified || (ptr->fFrame->GetX() != xw) ||
00891 (ptr->fFrame->GetY() != yw);
00892 ptr->fFrame->Move(xw, yw);
00893 y += (Int_t)max_osize.fHeight + fSep + (fSep >> 1);
00894
00895 if (y + max_osize.fHeight > max_height) {
00896 y = fSep << 1;
00897 x += (Int_t)max_osize.fWidth + fSep;
00898 }
00899 }
00900 }
00901
00902
00903 TGDimension TGListLayout::GetDefaultSize() const
00904 {
00905
00906
00907 TGFrameElement *ptr;
00908 Int_t x, y;
00909 TGDimension max_size, max_osize(0,0), msize = fMain->GetSize();
00910
00911 TIter next(fList);
00912 while ((ptr = (TGFrameElement *) next())) {
00913 max_size = ptr->fFrame->GetDefaultSize();
00914 max_osize.fWidth = TMath::Max(max_osize.fWidth, max_size.fWidth);
00915 max_osize.fHeight = TMath::Max(max_osize.fHeight, max_size.fHeight);
00916 }
00917
00918 max_size.fHeight = TMath::Max(msize.fHeight, max_osize.fHeight + (fSep << 1));
00919
00920 x = fSep; y = fSep << 1;
00921
00922 next.Reset();
00923 while ((ptr = (TGFrameElement *) next())) {
00924 y += (Int_t)max_osize.fHeight + fSep + (fSep >> 1);
00925 if (y + max_osize.fHeight > max_size.fHeight) {
00926 y = fSep << 1;
00927 x += (Int_t)max_osize.fWidth + fSep;
00928 }
00929 }
00930 if (y != (fSep << 1)) x += (Int_t)max_osize.fWidth + fSep;
00931 max_size.fWidth = TMath::Max(x, (Int_t)msize.fWidth);
00932
00933 return max_size;
00934 }
00935
00936
00937 void TGListDetailsLayout::Layout()
00938 {
00939
00940
00941 TGFrameElement *ptr;
00942 TGDimension csize, msize = fMain->GetSize();
00943 Int_t max_oh = 0, x = fSep, y = fSep << 1;
00944 fModified = kFALSE;
00945
00946 TIter next(fList);
00947 while ((ptr = (TGFrameElement *) next())) {
00948 csize = ptr->fFrame->GetDefaultSize();
00949 max_oh = TMath::Max(max_oh, (Int_t)csize.fHeight);
00950 }
00951
00952 next.Reset();
00953
00954 while ((ptr = (TGFrameElement *) next())) {
00955 if (ptr->fState & kIsVisible) {
00956 csize = ptr->fFrame->GetDefaultSize();
00957
00958 fModified = fModified || (ptr->fFrame->GetX() != x) ||
00959 (ptr->fFrame->GetY() != y);
00960
00961 ptr->fFrame->MoveResize(x, y, msize.fWidth, csize.fHeight);
00962 ptr->fFrame->Layout();
00963 y += max_oh + fSep + (fSep >> 1);
00964 }
00965 }
00966 }
00967
00968
00969 TGDimension TGListDetailsLayout::GetDefaultSize() const
00970 {
00971
00972
00973 TGFrameElement *ptr;
00974 TGDimension csize, max_osize(0,0);
00975 Int_t y = fSep << 1;
00976
00977 TIter next(fList);
00978 while ((ptr = (TGFrameElement *) next())) {
00979 csize = ptr->fFrame->GetDefaultSize();
00980 max_osize.fWidth = TMath::Max(max_osize.fWidth, csize.fWidth);
00981 max_osize.fHeight = TMath::Max(max_osize.fHeight, csize.fHeight);
00982 }
00983
00984 next.Reset();
00985 while ((ptr = (TGFrameElement *) next())) {
00986 if (ptr->fState & kIsVisible) {
00987 y += max_osize.fHeight + fSep + (fSep >> 1);
00988 }
00989 }
00990
00991 return TGDimension( fWidth ? fWidth : max_osize.fWidth, y);
00992 }
00993
00994
00995 void TGLayoutHints::SavePrimitive(ostream &out, Option_t * option)
00996 {
00997
00998
00999
01000 TString hints;
01001 UInt_t pad = GetPadLeft()+GetPadRight()+GetPadTop()+GetPadBottom();
01002
01003 if (!GetLayoutHints()) return;
01004
01005 if ((option == 0) || strcmp(option, "nocoma"))
01006 out << ", ";
01007
01008 if ((fLayoutHints == kLHintsNormal) && (pad == 0)) {
01009 out << "new TGLayoutHints(kLHintsNormal)";
01010 return;
01011 }
01012 if (fLayoutHints & kLHintsLeft) {
01013 if (hints.Length() == 0) hints = "kLHintsLeft";
01014 else hints += " | kLHintsLeft";
01015 }
01016 if (fLayoutHints & kLHintsCenterX) {
01017 if (hints.Length() == 0) hints = "kLHintsCenterX";
01018 else hints += " | kLHintsCenterX";
01019 }
01020 if (fLayoutHints & kLHintsRight) {
01021 if (hints.Length() == 0) hints = "kLHintsRight";
01022 else hints += " | kLHintsRight";
01023 }
01024 if (fLayoutHints & kLHintsTop) {
01025 if (hints.Length() == 0) hints = "kLHintsTop";
01026 else hints += " | kLHintsTop";
01027 }
01028 if (fLayoutHints & kLHintsCenterY) {
01029 if (hints.Length() == 0) hints = "kLHintsCenterY";
01030 else hints += " | kLHintsCenterY";
01031 }
01032 if (fLayoutHints & kLHintsBottom) {
01033 if (hints.Length() == 0) hints = "kLHintsBottom";
01034 else hints += " | kLHintsBottom";
01035 }
01036 if (fLayoutHints & kLHintsExpandX) {
01037 if (hints.Length() == 0) hints = "kLHintsExpandX";
01038 else hints += " | kLHintsExpandX";
01039 }
01040 if (fLayoutHints & kLHintsExpandY) {
01041 if (hints.Length() == 0) hints = "kLHintsExpandY";
01042 else hints += " | kLHintsExpandY";
01043 }
01044
01045 out << "new TGLayoutHints(" << hints;
01046
01047 if (pad) {
01048 out << "," << GetPadLeft() << "," << GetPadRight()
01049 << "," << GetPadTop() << "," << GetPadBottom();
01050 }
01051 out<< ")";
01052 }
01053
01054
01055 void TGVerticalLayout::SavePrimitive(ostream &out, Option_t * )
01056 {
01057
01058
01059
01060 out << "new TGVerticalLayout(" << fMain->GetName() << ")";
01061
01062 }
01063
01064
01065 void TGHorizontalLayout::SavePrimitive(ostream &out, Option_t * )
01066 {
01067
01068
01069
01070 out << "new TGHorizontalLayout(" << fMain->GetName() << ")";
01071 }
01072
01073
01074 void TGRowLayout::SavePrimitive(ostream &out, Option_t * )
01075 {
01076
01077
01078
01079 out << "new TGRowLayout(" << fMain->GetName() << ","
01080 << fSep << ")";
01081 }
01082
01083
01084 void TGColumnLayout::SavePrimitive(ostream &out, Option_t * )
01085 {
01086
01087
01088
01089 out << "new TGColumnLayout(" << fMain->GetName() << ","
01090 << fSep << ")";
01091
01092 }
01093
01094
01095 void TGMatrixLayout::SavePrimitive(ostream &out, Option_t * )
01096 {
01097
01098
01099
01100 out << "new TGMatrixLayout(" << fMain->GetName() << ","
01101 << fRows << ","
01102 << fColumns << ","
01103 << fSep << ","
01104 << fHints <<")";
01105
01106 }
01107
01108
01109 void TGTileLayout::SavePrimitive(ostream &out, Option_t * )
01110 {
01111
01112
01113
01114 out << "new TGTileLayout(" << fMain->GetName() << ","
01115 << fSep << ")";
01116
01117 }
01118
01119
01120 void TGListLayout::SavePrimitive(ostream &out, Option_t * )
01121 {
01122
01123
01124
01125 out << "new TGListLayout(" << fMain->GetName() << ","
01126 << fSep << ")";
01127
01128 }
01129
01130
01131 void TGListDetailsLayout::SavePrimitive(ostream &out, Option_t * )
01132 {
01133
01134
01135
01136 out << "new TGListDetailsLayout(" << fMain->GetName() << ","
01137 << fSep << "," << fWidth << ")";
01138
01139 }