本文整理汇总了C++中BLayoutItem::PreferredSize方法的典型用法代码示例。如果您正苦于以下问题:C++ BLayoutItem::PreferredSize方法的具体用法?C++ BLayoutItem::PreferredSize怎么用?C++ BLayoutItem::PreferredSize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BLayoutItem
的用法示例。
在下文中一共展示了BLayoutItem::PreferredSize方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: CountElements
void
BTwoDimensionalLayout::LocalLayouter::AddConstraints(
CompoundLayouter* compoundLayouter, Layouter* layouter)
{
enum orientation orientation = compoundLayouter->Orientation();
int itemCount = fLayout->CountItems();
if (itemCount > 0) {
for (int i = 0; i < itemCount; i++) {
BLayoutItem* item = fLayout->ItemAt(i);
if (item->IsVisible()) {
Dimensions itemDimensions;
fLayout->GetItemDimensions(item, &itemDimensions);
BSize min = item->MinSize();
BSize max = item->MaxSize();
BSize preferred = item->PreferredSize();
if (orientation == B_HORIZONTAL) {
layouter->AddConstraints(
itemDimensions.x,
itemDimensions.width,
min.width,
max.width,
preferred.width);
if (item->HasHeightForWidth())
fHeightForWidthItems.AddItem(item);
} else {
layouter->AddConstraints(
itemDimensions.y,
itemDimensions.height,
min.height,
max.height,
preferred.height);
}
}
}
// add column/row constraints
ColumnRowConstraints constraints;
int elementCount = CountElements(compoundLayouter);
for (int element = 0; element < elementCount; element++) {
fLayout->GetColumnRowConstraints(orientation, element,
&constraints);
layouter->SetWeight(element, constraints.weight);
layouter->AddConstraints(element, 1, constraints.min,
constraints.max, constraints.min);
}
}
}
示例2: CountItems
// _ValidateMinMax
void
BCardLayout::_ValidateMinMax()
{
if (fMinMaxValid)
return;
fMin.width = 0;
fMin.height = 0;
fMax.width = B_SIZE_UNLIMITED;
fMax.height = B_SIZE_UNLIMITED;
fPreferred.width = 0;
fPreferred.height = 0;
int32 itemCount = CountItems();
for (int32 i = 0; i < itemCount; i++) {
BLayoutItem* item = ItemAt(i);
BSize min = item->MinSize();
BSize max = item->MaxSize();
BSize preferred = item->PreferredSize();
fMin.width = max_c(fMin.width, min.width);
fMin.height = max_c(fMin.height, min.height);
fMax.width = min_c(fMax.width, max.width);
fMax.height = min_c(fMax.height, max.height);
fPreferred.width = max_c(fPreferred.width, preferred.width);
fPreferred.height = max_c(fPreferred.height, preferred.height);
}
fMax.width = max_c(fMax.width, fMin.width);
fMax.height = max_c(fMax.height, fMin.height);
fPreferred.width = max_c(fPreferred.width, fMin.width);
fPreferred.height = max_c(fPreferred.height, fMin.height);
fPreferred.width = min_c(fPreferred.width, fMax.width);
fPreferred.height = min_c(fPreferred.height, fMax.height);
fMinMaxValid = true;
if (BView* view = View())
view->ResetLayoutInvalidation();
}
示例3: CountItems
void
BSplitLayout::_ValidateMinMax()
{
if (fHorizontalLayouter != NULL)
return;
fLayoutValid = false;
fVisibleItems.MakeEmpty();
fHeightForWidthItems.MakeEmpty();
_InvalidateCachedHeightForWidth();
// filter the visible items
int32 itemCount = CountItems();
for (int32 i = 0; i < itemCount; i++) {
BLayoutItem* item = ItemAt(i);
if (item->IsVisible())
fVisibleItems.AddItem(item);
// Add "height for width" items even, if they aren't visible. Otherwise
// we may get our parent into trouble, since we could change from
// "height for width" to "not height for width".
if (item->HasHeightForWidth())
fHeightForWidthItems.AddItem(item);
}
itemCount = fVisibleItems.CountItems();
// create the layouters
Layouter* itemLayouter = new SimpleLayouter(itemCount, 0);
if (fOrientation == B_HORIZONTAL) {
fHorizontalLayouter = itemLayouter;
fVerticalLayouter = new OneElementLayouter();
} else {
fHorizontalLayouter = new OneElementLayouter();
fVerticalLayouter = itemLayouter;
}
// tell the layouters about our constraints
if (itemCount > 0) {
for (int32 i = 0; i < itemCount; i++) {
BLayoutItem* item = (BLayoutItem*)fVisibleItems.ItemAt(i);
BSize min = item->MinSize();
BSize max = item->MaxSize();
BSize preferred = item->PreferredSize();
fHorizontalLayouter->AddConstraints(i, 1, min.width, max.width,
preferred.width);
fVerticalLayouter->AddConstraints(i, 1, min.height, max.height,
preferred.height);
float weight = ItemWeight(item);
fHorizontalLayouter->SetWeight(i, weight);
fVerticalLayouter->SetWeight(i, weight);
}
}
fMin.width = fHorizontalLayouter->MinSize();
fMin.height = fVerticalLayouter->MinSize();
fMax.width = fHorizontalLayouter->MaxSize();
fMax.height = fVerticalLayouter->MaxSize();
fPreferred.width = fHorizontalLayouter->PreferredSize();
fPreferred.height = fVerticalLayouter->PreferredSize();
fHorizontalLayoutInfo = fHorizontalLayouter->CreateLayoutInfo();
if (fHeightForWidthItems.IsEmpty())
fVerticalLayoutInfo = fVerticalLayouter->CreateLayoutInfo();
ResetLayoutInvalidation();
}