CMS 3D CMS Logo

List of all members | Public Member Functions
FWCompactVerticalLayout Class Reference

#include <Fireworks/Core/interface/FWCompactVerticalLayout.h>

Inheritance diagram for FWCompactVerticalLayout:

Public Member Functions

 FWCompactVerticalLayout (TGCompositeFrame *iMain)
 
TGDimension GetDefaultSize () const override
 
void Layout () override
 
ClassDefOverride(FWCompactVerticalLayout, 0) private const FWCompactVerticalLayoutoperator= (const FWCompactVerticalLayout &)
 
 ~FWCompactVerticalLayout () override
 

Detailed Description

Description: <one line="" class="" summary>="">

Usage: <usage>

Definition at line 28 of file FWCompactVerticalLayout.h.

Constructor & Destructor Documentation

◆ FWCompactVerticalLayout()

FWCompactVerticalLayout::FWCompactVerticalLayout ( TGCompositeFrame *  iMain)

Definition at line 32 of file FWCompactVerticalLayout.cc.

32 : TGVerticalLayout(iMain) {}

◆ ~FWCompactVerticalLayout()

FWCompactVerticalLayout::~FWCompactVerticalLayout ( )
override

Definition at line 39 of file FWCompactVerticalLayout.cc.

39 {}

Member Function Documentation

◆ GetDefaultSize()

TGDimension FWCompactVerticalLayout::GetDefaultSize ( ) const
override

Definition at line 211 of file FWCompactVerticalLayout.cc.

References fileCollector2::fList, kIsVisible(), METSkim_cff::Max, GetRecoTauVFromDQM_MC_cff::next, and findQualityFiles::size.

211  {
212  // Return default dimension of the vertical layout.
213 
214  TGFrameElement *ptr;
215  TGDimension size(0, 0), msize = fMain->GetSize(), csize;
216  UInt_t options = fMain->GetOptions();
217 
218  if ((options & kFixedWidth) && (options & kFixedHeight))
219  return msize;
220 
221  TIter next(fList);
222  while ((ptr = (TGFrameElement *)next())) {
223  if (ptr->fState & kIsVisible) {
224  csize = ptr->fFrame->GetDefaultSize();
225  size.fWidth = TMath::Max(size.fWidth, csize.fWidth + ptr->fLayout->GetPadLeft() + ptr->fLayout->GetPadRight());
226  size.fHeight += csize.fHeight + ptr->fLayout->GetPadTop() + ptr->fLayout->GetPadBottom();
227  }
228  }
229 
230  size.fWidth += fMain->GetBorderWidth() << 1;
231  size.fHeight += fMain->GetBorderWidth() << 1;
232 
233  if (options & kFixedWidth)
234  size.fWidth = msize.fWidth;
235  if (options & kFixedHeight)
236  size.fHeight = msize.fHeight;
237 
238  return size;
239 }
size
Write out results.
static const std::string kIsVisible("isVisible")

◆ Layout()

void FWCompactVerticalLayout::Layout ( )
override

Definition at line 57 of file FWCompactVerticalLayout.cc.

References JetChargeProducer_cfi::exp, fileCollector2::fList, kIsVisible(), makeLayoutFileForGui::layout, METSkim_cff::Max, GetRecoTauVFromDQM_MC_cff::next, findQualityFiles::size, jetUpdater_cfi::sort, x, and y.

57  {
58  // Make a vertical layout of all frames in the list.
59 
60  TGFrameElement *ptr;
61  TGLayoutHints *layout;
62  Int_t nb_expand = 0;
63  Int_t top, bottom;
64  ULong_t hints;
65  UInt_t extra_space = 0;
66  Int_t exp = 0;
67  Int_t exp_max = 0;
68  Int_t remain;
69  Int_t x = 0, y = 0;
70  Int_t bw = fMain->GetBorderWidth();
71  TGDimension size(0, 0), csize(0, 0);
72  TGDimension msize = fMain->GetSize();
73  UInt_t pad_left, pad_top, pad_right, pad_bottom;
74  Int_t size_expand = 0, esize_expand = 0, rem_expand = 0, tmp_expand = 0;
75 
76  if (!fList)
77  return;
78 
79  fModified = kFALSE;
80 
81  bottom = msize.fHeight - (top = bw);
82  remain = msize.fHeight - (bw << 1);
83 
84  std::vector<int> expandSizes;
85  expandSizes.reserve(fList->GetSize());
86  TIter next(fList);
87  while ((ptr = (TGFrameElement *)next())) {
88  if (ptr->fState & kIsVisible) {
89  layout = ptr->fLayout;
90  size = ptr->fFrame->GetDefaultSize();
91  size.fHeight += layout->GetPadTop() + layout->GetPadBottom();
92  hints = layout->GetLayoutHints();
93  if ((hints & kLHintsExpandY) || (hints & kLHintsCenterY)) {
94  nb_expand++;
95  exp += size.fHeight;
96  if (hints & kLHintsExpandY) {
97  exp_max = 0;
98  expandSizes.push_back(size.fHeight);
99  } else
100  exp_max = TMath::Max(exp_max, (Int_t)size.fHeight);
101  } else {
102  remain -= size.fHeight;
103  if (remain < 0)
104  remain = 0;
105  }
106  }
107  }
108 
109  if (nb_expand) {
110  size_expand = remain / nb_expand;
111 
112  if (size_expand < exp_max)
113  esize_expand = (remain - exp) / nb_expand;
114  rem_expand = remain % nb_expand;
115  }
116 
117  std::sort(expandSizes.begin(), expandSizes.end(), std::less<int>());
118  //Now see if expanded widgets exceed their max sizes
119  for (std::vector<int>::iterator it = expandSizes.begin(), itEnd = expandSizes.end(); it != itEnd; ++it) {
120  if (*it > size_expand) {
121  break;
122  }
123  remain -= *it;
124  --nb_expand;
125  if (remain < 0) {
126  remain = 0;
127  }
128  if (nb_expand > 0) {
129  size_expand = remain / nb_expand;
130  } else {
131  size_expand = msize.fHeight - (bw << 1);
132  }
133  }
134 
135  next.Reset();
136  while ((ptr = (TGFrameElement *)next())) {
137  if (ptr->fState & kIsVisible) {
138  hints = (layout = ptr->fLayout)->GetLayoutHints();
139  csize = ptr->fFrame->GetDefaultSize();
140  pad_left = layout->GetPadLeft();
141  pad_top = layout->GetPadTop();
142  pad_right = layout->GetPadRight();
143  pad_bottom = layout->GetPadBottom();
144 
145  if (hints & kLHintsRight) {
146  x = msize.fWidth - bw - csize.fWidth - pad_right;
147  } else if (hints & kLHintsCenterX) {
148  x = (msize.fWidth - (bw << 1) - csize.fWidth) >> 1;
149  } else { // defaults to kLHintsLeft
150  x = pad_left + bw;
151  }
152 
153  if (hints & kLHintsExpandX) {
154  size.fWidth = msize.fWidth - (bw << 1) - pad_left - pad_right;
155  x = pad_left + bw;
156  } else {
157  size.fWidth = csize.fWidth;
158  }
159 
160  if (hints & kLHintsExpandY) {
161  if (size_expand >= exp_max)
162  if (static_cast<int>(csize.fHeight) > size_expand) {
163  size.fHeight = size_expand - pad_top - pad_bottom;
164  } else {
165  size.fHeight = csize.fHeight;
166  }
167  else
168  size.fHeight = csize.fHeight + esize_expand;
169 
170  tmp_expand += rem_expand;
171  if (tmp_expand >= nb_expand) {
172  size.fHeight++;
173  tmp_expand -= nb_expand;
174  }
175  } else {
176  size.fHeight = csize.fHeight;
177  if (hints & kLHintsCenterY) {
178  if (size_expand >= exp_max) {
179  extra_space = (size_expand - pad_top - pad_bottom - size.fHeight) >> 1;
180  } else {
181  extra_space = esize_expand >> 1;
182  }
183  top += extra_space;
184  }
185  }
186 
187  if (hints & kLHintsBottom) {
188  y = bottom - size.fHeight - pad_bottom;
189  bottom -= size.fHeight + pad_top + pad_bottom;
190  } else { // kLHintsTop by default
191  y = top + pad_top;
192  top += size.fHeight + pad_top + pad_bottom;
193  }
194 
195  if (hints & kLHintsCenterY)
196  top += extra_space;
197 
198  if (size.fWidth > 32768)
199  size.fWidth = 1;
200  if (size.fHeight > 32768)
201  size.fHeight = 1;
202  ptr->fFrame->MoveResize(x, y, size.fWidth, size.fHeight);
203 
204  fModified = fModified || (ptr->fFrame->GetX() != x) || (ptr->fFrame->GetY() != y) ||
205  (ptr->fFrame->GetWidth() != size.fWidth) || (ptr->fFrame->GetHeight() != size.fHeight);
206  }
207  }
208 }
size
Write out results.
static const std::string kIsVisible("isVisible")

◆ operator=()

ClassDefOverride (FWCompactVerticalLayout, 0) private const FWCompactVerticalLayout& FWCompactVerticalLayout::operator= ( const FWCompactVerticalLayout )