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


C++ BListItem::Select方法代码示例

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


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

示例1: locker

/*!	Selects the item at the specified \a index, and returns \c true in
	case the selection was changed because of this method.
	If \a extend is \c false, all previously selected items are deselected.
*/
bool
BListView::_Select(int32 index, bool extend)
{
    if (index < 0 || index >= CountItems())
        return false;

    // only lock the window when there is one
    BAutolock locker(Window());
    if (Window() != NULL && !locker.IsLocked())
        return false;

    bool changed = false;

    if (!extend && fFirstSelected != -1)
        changed = _DeselectAll(index, index);

    fAnchorIndex = index;

    BListItem* item = ItemAt(index);
    if (!item->IsEnabled() || item->IsSelected()) {
        // if the item is already selected, or can't be selected,
        // we're done here
        return changed;
    }

    // keep track of first and last selected item
    if (fFirstSelected == -1) {
        // no previous selection
        fFirstSelected = index;
        fLastSelected = index;
    } else if (index < fFirstSelected) {
        fFirstSelected = index;
    } else if (index > fLastSelected) {
        fLastSelected = index;
    }

    item->Select();
    if (Window() != NULL)
        InvalidateItem(index);

    return true;
}
开发者ID:mmuman,项目名称:haiku,代码行数:46,代码来源:ListView.cpp

示例2: locker

/*!
	Selects the items between \a from and \a to, and returns \c true in
	case the selection was changed because of this method.
	If \a extend is \c false, all previously selected items are deselected.
*/
bool
BListView::_Select(int32 from, int32 to, bool extend)
{
	if (to < from)
		return false;

	BAutolock locker(Window());
	if (Window() && !locker.IsLocked())
		return false;

	bool changed = false;

	if (fFirstSelected != -1 && !extend)
		changed = _DeselectAll(from, to);

	if (fFirstSelected == -1) {
		fFirstSelected = from;
		fLastSelected = to;
	} else {
		if (from < fFirstSelected)
			fFirstSelected = from;
		if (to > fLastSelected)
			fLastSelected = to;
	}

	for (int32 i = from; i <= to; ++i) {
		BListItem *item = ItemAt(i);
		if (item && !item->IsSelected()) {
			item->Select();
			if (Window())
				InvalidateItem(i);
			changed = true;
		}
	}

	return changed;
}
开发者ID:RAZVOR,项目名称:haiku,代码行数:42,代码来源:ListView.cpp


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