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


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

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


在下文中一共展示了BLayoutItem::HasHeightForWidth方法的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);
		}
	}
}
开发者ID:mariuz,项目名称:haiku,代码行数:51,代码来源:TwoDimensionalLayout.cpp

示例2: 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

示例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();
}
开发者ID:nielx,项目名称:haiku-serviceskit,代码行数:71,代码来源:SplitLayout.cpp


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