当前位置: 首页>>代码示例>>C++>>正文


C++ BLayoutItem::GetHeightForWidth方法代码示例

本文整理汇总了C++中BLayoutItem::GetHeightForWidth方法的典型用法代码示例。如果您正苦于以下问题:C++ BLayoutItem::GetHeightForWidth方法的具体用法?C++ BLayoutItem::GetHeightForWidth怎么用?C++ BLayoutItem::GetHeightForWidth使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在BLayoutItem的用法示例。


在下文中一共展示了BLayoutItem::GetHeightForWidth方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: CountItems

// GetHeightForWidth
void
BCardLayout::GetHeightForWidth(float width, float* min, float* max,
	float* preferred)
{
	_ValidateMinMax();

	// init with useful values
	float minHeight = fMin.height;
	float maxHeight = fMax.height;
	float preferredHeight = fPreferred.height;

	// apply the items' constraints
	int32 count = CountItems();
	for (int32 i = 0; i < count; i++) {
		BLayoutItem* item = ItemAt(i);
		if (item->HasHeightForWidth()) {
			float itemMinHeight;
			float itemMaxHeight;
			float itemPreferredHeight;
			item->GetHeightForWidth(width, &itemMinHeight, &itemMaxHeight,
				&itemPreferredHeight);
			minHeight = max_c(minHeight, itemMinHeight);
			maxHeight = min_c(maxHeight, itemMaxHeight);
			preferredHeight = min_c(preferredHeight, itemPreferredHeight);
		}
	}

	// adjust max and preferred, if necessary
	maxHeight = max_c(maxHeight, minHeight);
	preferredHeight = max_c(preferredHeight, minHeight);
	preferredHeight = min_c(preferredHeight, maxHeight);

	if (min)
		*min = minHeight;
	if (max)
		*max = maxHeight;
	if (preferred)
		*preferred = preferredHeight;
}
开发者ID:mariuz,项目名称:haiku,代码行数:40,代码来源:CardLayout.cpp

示例2:

bool
BTwoDimensionalLayout::LocalLayouter::AddHeightForWidthConstraints(
	VerticalCompoundLayouter* compoundLayouter, Layouter* layouter,
	BLayoutContext* context)
{
	if (context != fHorizontalLayoutContext)
		return false;

	if (fHeightForWidthConstraintsAdded)
		return false;

	LayoutInfo* hLayoutInfo = fHLayouter->GetLayoutInfo();

	// add the children's height for width constraints
	int32 itemCount = fHeightForWidthItems.CountItems();
	for (int32 i = 0; i < itemCount; i++) {
		BLayoutItem* item = (BLayoutItem*)fHeightForWidthItems.ItemAt(i);
		Dimensions itemDimensions;
		fLayout->GetItemDimensions(item, &itemDimensions);

		float minHeight, maxHeight, preferredHeight;
		item->GetHeightForWidth(
			hLayoutInfo->ElementRangeSize(itemDimensions.x,
				itemDimensions.width),
			&minHeight, &maxHeight, &preferredHeight);
		layouter->AddConstraints(
			itemDimensions.y,
			itemDimensions.height,
			minHeight,
			maxHeight,
			preferredHeight);
	}

	SetHeightForWidthConstraintsAdded(true);

	return true;
}
开发者ID:mariuz,项目名称:haiku,代码行数:37,代码来源:TwoDimensionalLayout.cpp

示例3:

void
BSplitLayout::_InternalGetHeightForWidth(float width, bool realLayout,
        float* minHeight, float* maxHeight, float* preferredHeight)
{
    if ((realLayout && fHeightForWidthVerticalLayouterWidth != width)
            || (!realLayout && fCachedHeightForWidthWidth != width)) {
        // The general strategy is to clone the vertical layouter, which only
        // knows the general min/max constraints, do a horizontal layout for the
        // given width, and add the children's height for width constraints to
        // the cloned vertical layouter. If this method is invoked internally,
        // we keep the cloned vertical layouter, for it will be used for doing
        // the layout. Otherwise we just drop it after we've got the height for
        // width info.

        // clone the vertical layouter and get the horizontal layout info to be used
        LayoutInfo* horizontalLayoutInfo = NULL;
        Layouter* verticalLayouter = fVerticalLayouter->CloneLayouter();
        if (realLayout) {
            horizontalLayoutInfo = fHorizontalLayoutInfo;
            delete fHeightForWidthVerticalLayouter;
            fHeightForWidthVerticalLayouter = verticalLayouter;
            delete fVerticalLayoutInfo;
            fVerticalLayoutInfo = verticalLayouter->CreateLayoutInfo();
            fHeightForWidthVerticalLayouterWidth = width;
        } else {
            if (fHeightForWidthHorizontalLayoutInfo == NULL) {
                delete fHeightForWidthHorizontalLayoutInfo;
                fHeightForWidthHorizontalLayoutInfo
                    = fHorizontalLayouter->CreateLayoutInfo();
            }
            horizontalLayoutInfo = fHeightForWidthHorizontalLayoutInfo;
        }

        // do the horizontal layout (already done when doing this for the real
        // layout)
        if (!realLayout)
            fHorizontalLayouter->Layout(horizontalLayoutInfo, width);

        // add the children's height for width constraints
        int32 count = fHeightForWidthItems.CountItems();
        for (int32 i = 0; i < count; i++) {
            BLayoutItem* item = (BLayoutItem*)fHeightForWidthItems.ItemAt(i);
            int32 index = fVisibleItems.IndexOf(item);
            if (index >= 0) {
                float itemMinHeight, itemMaxHeight, itemPreferredHeight;
                item->GetHeightForWidth(
                    horizontalLayoutInfo->ElementSize(index),
                    &itemMinHeight, &itemMaxHeight, &itemPreferredHeight);
                verticalLayouter->AddConstraints(index, 1, itemMinHeight,
                                                 itemMaxHeight, itemPreferredHeight);
            }
        }

        // get the height for width info
        fCachedHeightForWidthWidth = width;
        fCachedMinHeightForWidth = verticalLayouter->MinSize();
        fCachedMaxHeightForWidth = verticalLayouter->MaxSize();
        fCachedPreferredHeightForWidth = verticalLayouter->PreferredSize();
    }

    if (minHeight)
        *minHeight = fCachedMinHeightForWidth;
    if (maxHeight)
        *maxHeight = fCachedMaxHeightForWidth;
    if (preferredHeight)
        *preferredHeight = fCachedPreferredHeightForWidth;
}
开发者ID:nielx,项目名称:haiku-serviceskit,代码行数:67,代码来源:SplitLayout.cpp


注:本文中的BLayoutItem::GetHeightForWidth方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。