Пример #1
0
// _SetDropIndex
void
DragSortableListView::_SetDropIndex(int32 index)
{
	if (fDropIndex != index) {
		fDropIndex = index;
		if (fDropIndex >= 0) {
			int32 count = CountItems();
			if (fDropIndex == count) {
				BRect r;
				if (ItemAt(count - 1)) {
					r = ItemFrame(count - 1);
					r.top = r.bottom;
					r.bottom = r.top + 1.0;
				} else {
					r = Bounds();
					r.bottom--;	// compensate for scrollbars moved slightly out of window
				}
				_SetDropAnticipationRect(r);
			} else {
				BRect r = ItemFrame(fDropIndex);
				r.top--;
				r.bottom = r.top + 1.0;
				_SetDropAnticipationRect(r);
			}
		}
	}
}
Пример #2
0
bool
BListView::_MoveItem(int32 from, int32 to)
{
	// remember item frames before doing anything
	BRect frameFrom = ItemFrame(from);
	BRect frameTo = ItemFrame(to);

	if (!fList.MoveItem(from, to))
		return false;

	// track anchor item
	if (fAnchorIndex == from)
		fAnchorIndex = to;

	// track selection
	if (ItemAt(to)->IsSelected()) {
		_RescanSelection(from, to);
		// though the actually selected items stayed the
		// same, the selection has still changed
		SelectionChanged();
	}

	_RecalcItemTops((to > from) ? from : to);

	// take care of invalidation
	if (Window()) {
		// NOTE: window looper is assumed to be locked!
		Invalidate(frameFrom | frameTo);
	}

	return true;
}
Пример #3
0
bool
BListView::_SwapItems(int32 a, int32 b)
{
	// remember frames of items before anyhing happens,
	// the tricky situation is when the two items have
	// a different height
	BRect aFrame = ItemFrame(a);
	BRect bFrame = ItemFrame(b);

	if (!fList.SwapItems(a, b))
		return false;

	if (a == b) {
		// nothing to do, but success nevertheless
		return true;
	}

	// track anchor item
	if (fAnchorIndex == a)
		fAnchorIndex = b;
	else if (fAnchorIndex == b)
		fAnchorIndex = a;

	// track selection
	// NOTE: this is only important if the selection status
	// of both items is not the same
	int32 first = min_c(a, b);
	int32 last = max_c(a, b);
	if (ItemAt(a)->IsSelected() != ItemAt(b)->IsSelected()) {
		if (first < fFirstSelected || last > fLastSelected) {
			_RescanSelection(min_c(first, fFirstSelected),
				max_c(last, fLastSelected));
		}
		// though the actually selected items stayed the
		// same, the selection has still changed
		SelectionChanged();
	}

	ItemAt(a)->SetTop(aFrame.top);
	ItemAt(b)->SetTop(bFrame.top);

	// take care of invalidation
	if (Window()) {
		// NOTE: window looper is assumed to be locked!
		if (aFrame.Height() != bFrame.Height()) {
			_RecalcItemTops(first, last);
			// items in between shifted visually
			Invalidate(aFrame | bFrame);
		} else {
			Invalidate(aFrame);
			Invalidate(bFrame);
		}
	}

	return true;
}
void
LanguageListView::MouseMoved(BPoint where, uint32 transit,
	const BMessage* dragMessage)
{
	if (dragMessage != NULL && _AcceptsDragMessage(dragMessage)) {
		switch (transit) {
			case B_ENTERED_VIEW:
			case B_INSIDE_VIEW:
			{
				BRect highlightFrame;

				if (fGlobalDropTargetIndicator) {
					highlightFrame = Bounds();
					fDropIndex = 0;
				} else {
					// offset where by half of item height
					BRect r = ItemFrame(0);
					where.y += r.Height() / 2.0;

					int32 index = IndexOf(where);
					if (index < 0)
						index = CountItems();
					highlightFrame = ItemFrame(index);
					if (highlightFrame.IsValid())
						highlightFrame.bottom = highlightFrame.top;
					else {
						highlightFrame = ItemFrame(index - 1);
						if (highlightFrame.IsValid())
							highlightFrame.top = highlightFrame.bottom;
						else {
							// empty view, show indicator at top
							highlightFrame = Bounds();
							highlightFrame.bottom = highlightFrame.top;
						}
					}
					fDropIndex = index;
				}

				if (fDropTargetHighlightFrame != highlightFrame) {
					Invalidate(fDropTargetHighlightFrame);
					fDropTargetHighlightFrame = highlightFrame;
					Invalidate(fDropTargetHighlightFrame);
				}

				BOutlineListView::MouseMoved(where, transit, dragMessage);
				return;
			}
		}
	}

	if (fDropTargetHighlightFrame.IsValid()) {
		Invalidate(fDropTargetHighlightFrame);
		fDropTargetHighlightFrame = BRect();
	}
	BOutlineListView::MouseMoved(where, transit, dragMessage);
}
Пример #5
0
void BComboBox::ChoiceListView::InvalidateItem(int32 index, bool force)
{
	int32 choices = fParent->fChoiceList->CountChoices();
	if ((index >= 0 && index < choices) || force) {
		Invalidate(ItemFrame(index));
	}
}
Пример #6
0
// Draw
void
DragSortableListView::Draw(BRect updateRect)
{
	int32 firstIndex = IndexOf(updateRect.LeftTop());
	int32 lastIndex = IndexOf(updateRect.RightBottom());
	if (firstIndex >= 0) {
		if (lastIndex < firstIndex)
			lastIndex = CountItems() - 1;
		// update rect contains items
		BRect r = updateRect;
		for (int32 i = firstIndex; i <= lastIndex; i++) {
			r = ItemFrame(i);
			DrawListItem(this, i, r);
		}
		updateRect.top = r.bottom + 1.0;
		if (updateRect.IsValid()) {
			SetLowColor(255, 255, 255, 255);
			FillRect(updateRect, B_SOLID_LOW);
		}
	} else {
		SetLowColor(255, 255, 255, 255);
		FillRect(updateRect, B_SOLID_LOW);
	}
	// drop anticipation indication
	if (fDropRect.IsValid()) {
		SetHighColor(255, 0, 0, 255);
		StrokeRect(fDropRect);
	}
/*	// focus indication
	if (IsFocus()) {
		SetHighColor(ui_color(B_KEYBOARD_NAVIGATION_COLOR));
		StrokeRect(Bounds());
	}*/
}
Пример #7
0
// SetDropTargetRect
void
DragSortableListView::SetDropTargetRect(const BMessage* message, BPoint where)

{
	if (AcceptDragMessage(message)) {
		bool copy = modifiers() & B_SHIFT_KEY;
		bool replaceAll = !message->HasPointer("list") && !copy;
		BRect r = Bounds();
		if (replaceAll) {
			r.bottom--;	// compensate for scrollbar offset
			_SetDropAnticipationRect(r);
			fDropIndex = -1;
		} else {
			// offset where by half of item height
			r = ItemFrame(0);
			where.y += r.Height() / 2.0;
	
			int32 index = IndexOf(where);
			if (index < 0)
				index = CountItems();
			_SetDropIndex(index);

			const uchar* cursorData = copy ? kCopyCursor : B_HAND_CURSOR;
			BCursor cursor(cursorData);
			SetViewCursor(&cursor, true);
		}
	}
}
bool DraggableListView::InitiateDrag(BPoint point, int32 index, bool wasSelected) {
	uint32 buttons = Looper()->CurrentMessage()->FindInt32("buttons");
	if (buttons & B_PRIMARY_MOUSE_BUTTON) {
		snooze(200000);
		BPoint new_point;
		uint32 buttons;
		GetMouse(&new_point, &buttons);
		bool drag = ((new_point != point) && (buttons & B_PRIMARY_MOUSE_BUTTON));
		if (drag && list_type == addon) {
			if (!wasSelected)
				Select(index);
			BRect drag_rect;
			int32 current_item = CurrentSelection(0);
			int32 item_count = CountItems();
			drag_rect = ItemFrame(index);
			BMessage msg(SM_DRAG_FILTER);
			while (current_item < item_count) {
				if (ItemAt(current_item)->IsSelected()) {
					drag_rect = drag_rect | ItemFrame(current_item);
					if (list_type == filter) {
						msg.AddString("filter_name", ((FilterItem*)ItemAt(current_item))->Text());
						msg.AddInt32("filter_id", ((FilterItem*)ItemAt(current_item))->FilterID());
					} else {
						msg.AddString("filter_name", ((BStringItem*)ItemAt(current_item))->Text());
					}
				}
				current_item++;
			}
			DragMessage(&msg, drag_rect);
			current_item = CurrentSelection(0);
			return true;
		} else
				if (list_type == filter) {
					BMessage app_msg(SM_PREFS_VIEW);
					app_msg.AddInt32("filter_id", ((FilterItem*)ItemAt(index))->FilterID());
					be_app_messenger.SendMessage(&app_msg, Window());
				} else {
					BMessage app_msg(SM_ABOUT_VIEW);
					app_msg.AddString("addon_name", ((BStringItem*)ItemAt(index))->Text());
					be_app_messenger.SendMessage(&app_msg, Window());
				}
			return false;
	} else
		return false;
}
Пример #9
0
bool
BListView::_ReplaceItem(int32 index, BListItem* item)
{
	if (item == NULL)
		return false;

	BListItem* old = ItemAt(index);
	if (!old)
		return false;

	BRect frame = ItemFrame(index);

	bool selectionChanged = old->IsSelected() != item->IsSelected();

	// replace item
	if (!fList.ReplaceItem(index, item))
		return false;

	// tack selection
	if (selectionChanged) {
		int32 start = min_c(fFirstSelected, index);
		int32 end = max_c(fLastSelected, index);
		_RescanSelection(start, end);
		SelectionChanged();
	}
	_RecalcItemTops(index);

	bool itemHeightChanged = frame != ItemFrame(index);

	// take care of invalidation
	if (Window()) {
		// NOTE: window looper is assumed to be locked!
		if (itemHeightChanged)
			_InvalidateFrom(index);
		else
			Invalidate(frame);
	}

	if (itemHeightChanged)
		_FixupScrollBar();

	return true;
}
Пример #10
0
void _ArpControllerRangeList::AttachedToWindow()
{
	inherited::AttachedToWindow();

	int32	item = first_active_item(this);
	if (item > 2) {
		BRect		frame = ItemFrame(item - 2);
		ScrollTo(0, frame.top);
	}
}
Пример #11
0
void
ClipView::Draw(BRect rect)
{
	SetHighColor(ui_color(B_CONTROL_BACKGROUND_COLOR));

	BRect bounds(Bounds());
	BRect itemFrame = ItemFrame(CountItems() - 1);
	bounds.top = itemFrame.bottom;
	FillRect(bounds);

	BListView::Draw(rect);
}
Пример #12
0
void
AudioListView::MouseMoved(BPoint where, uint32 transit,
	const BMessage* dragMessage)
{
	if (dragMessage != NULL) {
		switch (transit) {
			case B_ENTERED_VIEW:
			case B_INSIDE_VIEW:
			{
				int32 index = IndexOf(where);
				if (index < 0)
					index = CountItems();

				fDropRect = ItemFrame(index);
				if (fDropRect.IsValid()) {
					fDropRect.top = fDropRect.top -1;
					fDropRect.bottom = fDropRect.top + 1;
				} else {
					fDropRect = ItemFrame(index - 1);
					if (fDropRect.IsValid())
						fDropRect.top = fDropRect.bottom - 1;
					else {
						// empty view, show indicator at top
						fDropRect = Bounds();
						fDropRect.bottom = fDropRect.top + 1;
					}
				}
				Invalidate();
				break;
			}
			case B_EXITED_VIEW:
			{
				fDropRect = BRect(-1, -1, -1, -1);
				Invalidate();
				break;
			}
		}
	}
	BListView::MouseMoved(where, transit, dragMessage);
}
Пример #13
0
void
BOutlineListView::SortItemsUnder(BListItem* underItem, bool oneLevelOnly,
	int (*compareFunc)(const BListItem* a, const BListItem* b))
{
	// This method is quite complicated: basically, it creates a real tree
	// from the items of the full list, sorts them as needed, and then
	// populates the entries back into the full and display lists

	int32 firstIndex = FullListIndexOf(underItem) + 1;
	int32 lastIndex = firstIndex;
	BList* tree = _BuildTree(underItem, lastIndex);

	_SortTree(tree, oneLevelOnly, compareFunc);

	// Populate to the full list
	_PopulateTree(tree, fFullList, firstIndex, false);

	if (underItem == NULL
		|| (underItem->IsItemVisible() && underItem->IsExpanded())) {
		// Populate to BListView's list
		firstIndex = fList.IndexOf(underItem) + 1;
		lastIndex = firstIndex;
		_PopulateTree(tree, fList, lastIndex, true);

		if (fFirstSelected != -1) {
			// update selection hints
			fFirstSelected = _CalcFirstSelected(0);
			fLastSelected = _CalcLastSelected(CountItems());
		}

		// only invalidate what may have changed
		_RecalcItemTops(firstIndex);
		BRect top = ItemFrame(firstIndex);
		BRect bottom = ItemFrame(lastIndex - 1);
		BRect update(top.left, top.top, bottom.right, bottom.bottom);
		Invalidate(update);
	}

	_DestructTree(tree);
}
Пример #14
0
void
BListView::ScrollToSelection()
{
	BRect itemFrame = ItemFrame(CurrentSelection(0));

	if (Bounds().Contains(itemFrame))
		return;

	if (itemFrame.top < Bounds().top)
		ScrollTo(itemFrame.left, itemFrame.top);
	else
		ScrollTo(itemFrame.left, itemFrame.bottom - Bounds().Height());
}
Пример #15
0
InterfaceListItem*
InterfacesListView::FindItem(BPoint where)
{
	for (int32 i = CountItems(); i-- > 0;) {
		InterfaceListItem* item = dynamic_cast<InterfaceListItem*>(ItemAt(i));
		if (item == NULL)
			continue;

		if (ItemFrame(i).Contains(where))
			return item;
	}

	return NULL;
}
Пример #16
0
/*****************************************************************************
 * DragSortableListView::MouseMoved
 *****************************************************************************/
void
DragSortableListView::MouseMoved(BPoint where, uint32 transit, const BMessage *msg)
{
    if ( msg && ( msg->what == B_SIMPLE_DATA || msg->what == MSG_SOUNDPLAY ) )
    {
        bool replaceAll = !msg->HasPointer("list") && !(modifiers() & B_SHIFT_KEY);
        switch ( transit )
        {
            case B_ENTERED_VIEW:
                // remember drag message
                // this is needed to react on modifier changes
                fDragMessageCopy = *msg;
            case B_INSIDE_VIEW:
            {
                if ( replaceAll )
                {
                    BRect r( Bounds() );
                    r.bottom--;    // compensate for scrollbar offset
                    _SetDropAnticipationRect( r );
                    fDropIndex = -1;
                }
                else
                {
                    // offset where by half of item height
                    BRect r( ItemFrame( 0 ) );
                    where.y += r.Height() / 2.0;
    
                    int32 index = IndexOf( where );
                    if ( index < 0 )
                        index = CountItems();
                    _SetDropIndex( index );
                }
                break;
            }
            case B_EXITED_VIEW:
                // forget drag message
                fDragMessageCopy.what = 0;
            case B_OUTSIDE_VIEW:
                _RemoveDropAnticipationRect();
                break;
        }
    }
    else
    {
        _RemoveDropAnticipationRect();
        BListView::MouseMoved(where, transit, msg);
        fDragMessageCopy.what = 0;
    }
}
Пример #17
0
/***********************************************************
 * MouseDown
 ***********************************************************/
void
HCoolListView::MouseMoved(BPoint where,uint32 code,const BMessage *message)
{
	_inherited::MouseMoved(where,code,message);
	if(!fHovering)
		return;
	if(!Window()->IsActive())
		return;
	int32 count = CountItems();
	if(count == 0)
		return;
	BRect itemRect = ItemFrame(0);
	float itemHeight = itemRect.Height()+1;
	
	//itemRect.OffsetBy(0,-1);
	
	if(fOldSelection >= 0 && (code == B_EXITED_VIEW || code == B_OUTSIDE_VIEW))
	{
		BRect oldRect = itemRect;
		oldRect.OffsetBy(0,itemHeight*fOldSelection);
		fOldSelection = -1;
		Invalidate(oldRect);
		return;
	}
	
	BRect newRect = itemRect;
	for(int32 i = 0;i < count;i++)
	{
		if(newRect.Contains(where))
		{
			if(i == fOldSelection)
				break;
			
			if(fOldSelection >= 0)
			{
				BRect oldRect = itemRect;
				oldRect.OffsetBy(0,itemHeight*fOldSelection);
				fOldSelection = -1;
				Invalidate(oldRect);
			}
			SetHighColor(highlight);
			SetDrawingMode(B_OP_ALPHA);
			FillRect(newRect);
			fOldSelection = i;
			break;
		}
		newRect.OffsetBy(0,itemHeight);
	}	
}
Пример #18
0
void
HTGListView::MouseDown(BPoint point)
{
	BListView::MouseDown(point);
	
	int index = CurrentSelection();
	if(index < 0)
		return;
	
	HTGTweetItem* clickedItem = (HTGTweetItem*)ItemAt(index);
	if(clickedItem == NULL)
		return;
	
	int32 buttons;
	Window()->CurrentMessage()->FindInt32("buttons", &buttons);
	
	if ((buttons & B_PRIMARY_MOUSE_BUTTON) != 0) {
		clickedItem->LeftClicked(point, this, ItemFrame(index));
	}
	
	else if((buttons & B_SECONDARY_MOUSE_BUTTON) != 0) {
		clickedItem->RightClicked(point, this, ItemFrame(index));
	}
}
Пример #19
0
bool MyListView::InitiateDrag(BPoint point, int32 index, bool wasSelected)
{
	BMessage msg(B_MIME_DATA);
	MyItem *item;
	
	if (wasSelected && doDrags) {
		item = cast_as(ItemAt(index), MyItem);
		const char * text = item->DragStr();
		msg.AddData("text/plain", B_MIME_TYPE, text, strlen(text));
		DragMessage(&msg, ItemFrame(index));  // drag an outline
		return true;
	} else {
		return false;
	}
}
Пример #20
0
/*****************************************************************************
 * PlaylistView::MouseDown
 *****************************************************************************/
void
PlaylistView::MouseDown( BPoint where )
{
    int32 clicks = 1;
    Window()->CurrentMessage()->FindInt32( "clicks", &clicks );
    bool handled = false;
    for ( int32 i = 0; PlaylistItem* item = (PlaylistItem*)ItemAt( i ); i++ )
    {
        BRect r = ItemFrame( i );
        if ( r.Contains( where ) )
        {
            if ( clicks == 2 )
            {
                // only do something if user clicked the same item twice
                if ( fLastClickedItem == item )
                {
                    playlist_t * p_playlist;
                    p_playlist = (playlist_t *) vlc_object_find( p_intf,
                        VLC_OBJECT_PLAYLIST, FIND_ANYWHERE );
                    if( p_playlist )
                    {
                        playlist_Goto( p_playlist, i );
                        vlc_object_release( p_playlist );
                    }
                    handled = true;
                }
            }
            else
            {
                // remember last clicked item
                fLastClickedItem = item;
                if ( i == fCurrentIndex )
                {
                    r.right = r.left + TEXT_OFFSET;
                    if ( r.Contains ( where ) )
                    {
                        fMainWindow->PostMessage( PAUSE_PLAYBACK );
                        InvalidateItem( i );
                        handled = true;
                    }
                }
            }
            break;
        }
    }
    if ( !handled )
        DragSortableListView::MouseDown(where);
}
Пример #21
0
void
BListView::ScrollToSelection()
{
	BRect itemFrame = ItemFrame(CurrentSelection(0));

	if (Bounds().Contains(itemFrame))
		return;

	float scrollPos = itemFrame.top < Bounds().top ?
		itemFrame.top : itemFrame.bottom - Bounds().Height();

	if (itemFrame.top - scrollPos < Bounds().top)
		scrollPos = itemFrame.top;

	ScrollTo(itemFrame.left, scrollPos);
}
Пример #22
0
void
AudioListView::Draw(BRect rect)
{
	SetHighColor(ui_color(B_CONTROL_BACKGROUND_COLOR));

	BRect bounds(Bounds());
	BRect itemFrame = ItemFrame(CountItems() - 1);
	bounds.top = itemFrame.bottom;
	FillRect(bounds);

	BListView::Draw(rect);

	if (fDropRect.IsValid()) {
		SetHighColor(255, 0, 0, 255);
		StrokeRect(fDropRect);
	}
}
Пример #23
0
void
BListView::_InvalidateFrom(int32 index)
{
	// make sure index is behind last valid index
	int32 count = CountItems();
	if (index >= count)
		index = count;

	// take the item before the wanted one,
	// because that might already be removed
	index--;
	BRect dirty = Bounds();
	if (index >= 0)
		dirty.top = ItemFrame(index).bottom + 1;

	Invalidate(dirty);
}
Пример #24
0
bool DormantNodeView::InitiateDrag(
	BPoint point,
	int32 index,
	bool wasSelected) {
	D_HOOK(("DormantNodeView::InitiateDrag()\n"));

	DormantNodeListItem *item = dynamic_cast<DormantNodeListItem *>(ItemAt(CurrentSelection()));
	if (item) {
		BMessage dragMsg(M_INSTANTIATE_NODE);
		dragMsg.AddData("which", B_RAW_TYPE,
						reinterpret_cast<const void *>(&item->info()),
						sizeof(item->info()));
		point -= ItemFrame(index).LeftTop();
		DragMessage(&dragMsg, item->getDragBitmap(), B_OP_ALPHA, point);
		return true;
	}
	return false;
}
Пример #25
0
// ScrollTo
void
DragSortableListView::ScrollTo(int32 index)
{
	if (index < 0)
		index = 0;
	if (index >= CountItems())
		index = CountItems() - 1;

	if (ItemAt(index)) {
		BRect itemFrame = ItemFrame(index);
		BRect bounds = Bounds();
		if (itemFrame.top < bounds.top) {
			ScrollTo(itemFrame.LeftTop());
		} else if (itemFrame.bottom > bounds.bottom) {
			ScrollTo(BPoint(0.0, itemFrame.bottom - bounds.Height()));
		}
	}
}
Пример #26
0
void
ClipView::MouseDown(BPoint position)
{
	BListView::MouseDown(position);

	BMessage message(SWITCHLIST);
	message.AddInt32("listview", (int32)1);
	Looper()->PostMessage(&message);

	BRect bounds = ItemFrame(CurrentSelection());
	if (bounds.Contains(position)) {
		uint32 buttons = 0;
		if (Window() != NULL && Window()->CurrentMessage() != NULL)
			buttons = Window()->CurrentMessage()->FindInt32("buttons");

		if (buttons == B_SECONDARY_MOUSE_BUTTON)
			_ShowPopUpMenu(ConvertToScreen(position));
	}
}
Пример #27
0
void
BOutlineListView::MouseDown(BPoint point)
{
	MakeFocus();

	int32 index = IndexOf(point);

	if (index != -1) {
		BListItem* item = ItemAt(index);

		if (item->fHasSubitems
			&& LatchRect(ItemFrame(index), item->fLevel).Contains(point)) {
			if (item->IsExpanded())
				Collapse(item);
			else
				Expand(item);
		} else
			BListView::MouseDown(point);
	}
}
Пример #28
0
bool
BOutlineListView::AddItem(BListItem* item, int32 fullListIndex)
{
	if (fullListIndex < 0)
		fullListIndex = 0;
	else if (fullListIndex > FullListCountItems())
		fullListIndex = FullListCountItems();

	if (!fFullList.AddItem(item, fullListIndex))
		return false;

	// Check if this item is visible, and if it is, add it to the
	// other list, too

	if (item->fLevel > 0) {
		BListItem* super = _SuperitemForIndex(fullListIndex, item->fLevel);
		if (super == NULL)
			return true;

		bool hadSubitems = super->fHasSubitems;
		super->fHasSubitems = true;

		if (!super->IsItemVisible() || !super->IsExpanded()) {
			item->SetItemVisible(false);
			return true;
		}

		if (!hadSubitems)
			Invalidate(LatchRect(ItemFrame(IndexOf(super)), super->OutlineLevel()));
	}

	int32 listIndex = _FindPreviousVisibleIndex(fullListIndex);

	if (!BListView::AddItem(item, IndexOf(FullListItemAt(listIndex)) + 1)) {
		// adding didn't work out, we need to remove it from the main list again
		fFullList.RemoveItem(fullListIndex);
		return false;
	}

	return true;
}
Пример #29
0
bool
PrefListView::InitiateDrag(BPoint point, int32 index, bool wasSelected)
{
	BOutlineListView::InitiateDrag(point,index,wasSelected);
	if (wasSelected) {
		int idx = IndexOf(point);
		if (idx == B_ERROR)
			return false;
		BStringItem* item = (BStringItem*)ItemAt(idx);
		BRect r = ItemFrame(idx);
		
		BMessage msg('ITEM');
		msg.AddInt32("Item", (int)item);
		msg.AddInt32("Item_nr", (int)index);
		msg.AddPoint("click_location", point);
		
		DragMessage( &msg, r, NULL );
		return true;
	}
	return false;
}
Пример #30
0
bool
CTrackListView::InitiateDrag(
	BPoint point,
	int32 index,
	bool wasSelected)
{
	D_HOOK(("CTrackListView::InitiateDrag()\n"));

	CTrackListItem *item = dynamic_cast<CTrackListItem *>(ItemAt(index));
	if (item)
	{
		BMessage dragMsg(MeVDragMsg_ID);
		dragMsg.AddInt32("Type", DragTrack_ID);
		dragMsg.AddInt32("TrackID", item->GetTrackID());
		dragMsg.AddInt32("Index", index);
		dragMsg.AddPointer("Document", m_doc);
		point -= ItemFrame(index).LeftTop();
		DragMessage(&dragMsg, item->GetDragBitmap(), B_OP_ALPHA, point);
		return true;
	}
	return false;
}