本文整理汇总了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;
}
示例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;
}