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


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

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


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

示例1: ItemAt

BListItem*
BListView::RemoveItem(int32 index)
{
	BListItem* item = ItemAt(index);
	if (item == NULL)
		return NULL;

	if (item->IsSelected())
		Deselect(index);

	if (!fList.RemoveItem(item))
		return NULL;

	if (fFirstSelected != -1 && index < fFirstSelected)
		fFirstSelected--;

	if (fLastSelected != -1 && index < fLastSelected)
		fLastSelected--;

	if (fAnchorIndex != -1 && index < fAnchorIndex)
		fAnchorIndex--;

	_RecalcItemTops(index);

	_InvalidateFrom(index);
	_FixupScrollBar();

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

示例2: sqrtf

void
BListView::_Track(BPoint where, uint32)
{
    if (fTrack->item_index >= 0 && fTrack->try_drag) {
        // initiate a drag if the mouse was moved far enough
        BPoint offset = where - fTrack->drag_start;
        float dragDistance = sqrtf(offset.x * offset.x + offset.y * offset.y);
        if (dragDistance >= 5.0f) {
            fTrack->try_drag = false;
            fTrack->is_dragging = InitiateDrag(fTrack->drag_start,
                                               fTrack->item_index, fTrack->was_selected);
        }
    }

    if (!fTrack->is_dragging) {
        // do selection only if a drag was not initiated
        int32 index = IndexOf(where);
        BListItem* item = ItemAt(index);
        if (item != NULL && !item->IsSelected() && item->IsEnabled()) {
            Select(index, fListType == B_MULTIPLE_SELECTION_LIST
                   && (modifiers() & B_SHIFT_KEY) != 0);
            ScrollToSelection();
        }
    }
}
开发者ID:mmuman,项目名称:haiku,代码行数:25,代码来源:ListView.cpp

示例3: ItemAt

void
AudioListView::MouseDown(BPoint position)
{
	if (!IsEmpty()) {
		bool onSelection = false;
		BListItem* item = ItemAt(IndexOf(position));

		if (item != NULL && item->IsSelected())
			onSelection = true;

		uint32 buttons = 0;
		if (Window() != NULL && Window()->CurrentMessage() != NULL)
			buttons = Window()->CurrentMessage()->FindInt32("buttons");

		if ((buttons & B_SECONDARY_MOUSE_BUTTON) != 0) {

			if (CurrentSelection() < 0 || !onSelection)
				Select(IndexOf(position));

			if (CurrentSelection() >= 0)
				_ShowPopUpMenu(ConvertToScreen(position));
			return;
		}
	}

	BListView::MouseDown(position);
}
开发者ID:HaikuArchives,项目名称:BurnItNow,代码行数:27,代码来源:AudioList.cpp

示例4: 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;
	}

	ItemAt(index)->Select();
	if (Window())
		InvalidateItem(index);

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

示例5: IndexOfSelectable

// ObjectChanged
void
DragSortableListView::ObjectChanged(const Observable* object)
{
	if (object != fSelection || fModifyingSelection || fSyncingToSelection)
		return;

//printf("%s - syncing start\n", Name());
	fSyncingToSelection = true;

	// try to sync to Selection
	BList selectedItems;

	int32 count = fSelection->CountSelected();
	for (int32 i = 0; i < count; i++) {
		int32 index = IndexOfSelectable(fSelection->SelectableAtFast(i));
		if (index >= 0) {
			BListItem* item = ItemAt(index);
			if (item && !selectedItems.HasItem((void*)item))
				selectedItems.AddItem((void*)item);
		}
	}

	count = selectedItems.CountItems();
	if (count == 0) {
		if (CurrentSelection(0) >= 0)
			DeselectAll();
	} else {
		count = CountItems();
		for (int32 i = 0; i < count; i++) {
			BListItem* item = ItemAt(i);
			bool selected = selectedItems.RemoveItem((void*)item);
			if (item->IsSelected() != selected) {
				Select(i, true);
			}
		}
	}

	fSyncingToSelection = false;
//printf("%s - done\n", Name());
}
开发者ID:DonCN,项目名称:haiku,代码行数:41,代码来源:ListViews.cpp

示例6: ItemAt

// MouseDown
void
DragSortableListView::MouseDown( BPoint where )
{
	int32 clicks = 1;
	uint32 buttons = 0;
	Window()->CurrentMessage()->FindInt32("clicks", &clicks);
	Window()->CurrentMessage()->FindInt32("buttons", (int32*)&buttons);
	int32 clickedIndex = -1;
	for (int32 i = 0; BListItem* item = ItemAt(i); i++) {
		if (ItemFrame(i).Contains(where)) {
			if (clicks == 2) {
				// only do something if user clicked the same item twice
				if (fLastClickedItem == item)
					DoubleClicked(i);
			} else {
				// remember last clicked item
				fLastClickedItem = item;
			}
			clickedIndex = i;
			break;
		}
	}
	if (clickedIndex == -1)
		fLastClickedItem = NULL;

	BListItem* item = ItemAt(clickedIndex);
	if (ListType() == B_MULTIPLE_SELECTION_LIST
		&& item && (buttons & B_SECONDARY_MOUSE_BUTTON)) {
		if (item->IsSelected())
			Deselect(clickedIndex);
		else
			Select(clickedIndex, true);
	} else {
		BListView::MouseDown(where);
	}
}
开发者ID:,项目名称:,代码行数:37,代码来源:

示例7: selected

void
NamesView::MouseDown (BPoint myPoint)
{
	int32 selected (IndexOf (myPoint));
	bool handled (false);

	if (selected < 0)
	{
		DeselectAll();
		return;
	}

	BMessage *inputMsg (Window()->CurrentMessage());
	int32 mousebuttons (0),
				keymodifiers (0),
				mouseclicks (0);

	inputMsg->FindInt32 ("buttons", &mousebuttons);
	inputMsg->FindInt32 ("modifiers", &keymodifiers);
	inputMsg->FindInt32 ("clicks",	&mouseclicks);

	if (mouseclicks > 1
	&& CurrentSelection(1) <= 0
	&&	mousebuttons == B_PRIMARY_MOUSE_BUTTON
	&& (keymodifiers & B_SHIFT_KEY)	 == 0
	&& (keymodifiers & B_OPTION_KEY)	== 0
	&& (keymodifiers & B_COMMAND_KEY) == 0
	&& (keymodifiers & B_CONTROL_KEY) == 0)
	{
		// user double clicked

		BListItem *item (ItemAt (IndexOf(myPoint)));
		if (item && !item->IsSelected())
		{
			// "double" clicked away from another selection
			Select (IndexOf (myPoint), false);
			fCurrentindex = IndexOf (myPoint);
			fTracking = true;
		}
		else if (item && item->IsSelected())
		{
			// double clicking on a single item
			NameItem *myItem (reinterpret_cast<NameItem *>(item));
			BString theNick (myItem->Name());
			BMessage msg (M_OPEN_MSGAGENT);

			msg.AddString ("nick", theNick.String());
			reinterpret_cast<ChannelAgent *>(Parent()->Parent())->fMsgr.SendMessage (&msg);
		}

		handled = true;
	}

	if (mouseclicks == 1
	&&	CurrentSelection(1) <= 0
	&&	mousebuttons == B_PRIMARY_MOUSE_BUTTON
	&& (keymodifiers & B_SHIFT_KEY)	 == 0
	&& (keymodifiers & B_OPTION_KEY)	== 0
	&& (keymodifiers & B_COMMAND_KEY) == 0
	&& (keymodifiers & B_CONTROL_KEY) == 0)
	{
		// user single clicks
		BListItem *item (ItemAt (IndexOf(myPoint)));
		if (item && !item->IsSelected())
			Select (IndexOf (myPoint), false);

		fTracking = true;
		fCurrentindex = IndexOf (myPoint);
		handled = true;
	}

	if (mouseclicks >= 1
	&&	CurrentSelection(1) >= 0
	&&	mousebuttons == B_PRIMARY_MOUSE_BUTTON
	&& (keymodifiers & B_SHIFT_KEY)	 == 0
	&& (keymodifiers & B_OPTION_KEY)	== 0
	&& (keymodifiers & B_COMMAND_KEY) == 0
	&& (keymodifiers & B_CONTROL_KEY) == 0)
	{
		// user clicks on something in the middle of a sweep selection
		BListItem *item (ItemAt (IndexOf(myPoint)));
		if (item)
			Select (IndexOf (myPoint), false);

		fTracking = true;
		fCurrentindex = IndexOf (myPoint);
		handled = true;
	}

	if (mousebuttons == B_SECONDARY_MOUSE_BUTTON
	&& (keymodifiers & B_SHIFT_KEY)	 == 0
	&& (keymodifiers & B_OPTION_KEY)	== 0
	&& (keymodifiers & B_COMMAND_KEY) == 0
	&& (keymodifiers & B_CONTROL_KEY) == 0)
	{
		// user right clicks - display popup menu
		BListItem *item (ItemAt (IndexOf(myPoint)));
		if (item && !item->IsSelected())
			Select (IndexOf (myPoint), false);

//.........这里部分代码省略.........
开发者ID:jessicah,项目名称:Vision,代码行数:101,代码来源:NamesView.cpp


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