本文整理汇总了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;
}
示例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();
}
}
}
示例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);
}
示例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;
}
示例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());
}
示例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);
}
}
示例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);
//.........这里部分代码省略.........