BOOL LLFloaterAvatarPicker::handleDragAndDrop(S32 x, S32 y, MASK mask,
											  BOOL drop, EDragAndDropType cargo_type,
											  void *cargo_data, EAcceptance *accept,
											  std::string& tooltip_msg)
{
	LLScrollListCtrl* list = getActiveList();
	if(list)
	{
		LLRect rc_list;
		LLRect rc_point(x,y,x,y);
		if (localRectToOtherView(rc_point, &rc_list, list))
		{
			// Keep selected only one item
			list->deselectAllItems(TRUE);
			list->selectItemAt(rc_list.mLeft, rc_list.mBottom, mask);
			LLScrollListItem* selection = list->getFirstSelected();
			if (selection)
			{
				LLUUID session_id = LLUUID::null;
				LLUUID dest_agent_id = selection->getUUID();
				std::string avatar_name = selection->getColumn(0)->getValue().asString();
				if (dest_agent_id.notNull() && dest_agent_id != gAgentID)
				{
//					if (drop)
// [RLVa:KB] - Checked: 2011-04-11 (RLVa-1.3.0h) | Added: RLVa-1.3.0h
					if ( (drop) && ( (!rlv_handler_t::isEnabled()) || (gRlvHandler.canStartIM(dest_agent_id)) ) )
// [/RLVa:KB]
					{
						// Start up IM before give the item
						session_id = gIMMgr->addSession(avatar_name, IM_NOTHING_SPECIAL, dest_agent_id);
					}
					return LLToolDragAndDrop::handleGiveDragAndDrop(dest_agent_id, session_id, drop,
																	cargo_type, cargo_data, accept, getName());
				}
			}
		}
	}
	*accept = ACCEPT_NO;
	return TRUE;
}
S32 LLExpandableTextBox::recalculateTextDelta(S32 text_delta)
{
	LLRect expanded_rect = getLocalRect();
	LLView* root_view = getRootView();
	LLRect window_rect = root_view->getRect();

	LLRect expanded_screen_rect;
	localRectToOtherView(expanded_rect, &expanded_screen_rect, root_view);

	// don't allow expanded text box bottom go off screen
	if(expanded_screen_rect.mBottom - text_delta < window_rect.mBottom)
	{
		text_delta = expanded_screen_rect.mBottom - window_rect.mBottom;
	}
	// show scroll bar if max_height is valid 
	// and expanded size is greater that max_height
	else if(mMaxHeight > 0 && expanded_rect.getHeight() + text_delta > mMaxHeight)
	{
		text_delta = mMaxHeight - expanded_rect.getHeight();
	}

	return text_delta;
}
void LLExpandableTextBox::expandTextBox()
{
	// hide "more" link, and show full text contents
	mTextBox->hideExpandText();

	// *HACK dz
	// hideExpandText brakes text styles (replaces hyper-links with plain text), see ticket EXT-3290
	// Set text again to make text box re-apply styles.
	// *TODO Find proper solution to fix this issue.
	// Maybe add removeSegment to LLTextBase
	mTextBox->setTextBase(mText);

	S32 text_delta = mTextBox->getVerticalTextDelta();
	text_delta += mTextBox->getVPad() * 2;
	text_delta += mScroll->getBorderWidth() * 2;
	// no need to expand
	if(text_delta <= 0)
	{
		return;
	}

	saveCollapsedState();

	LLRect expanded_rect = getLocalRect();
	LLRect expanded_screen_rect;

	S32 updated_text_delta = recalculateTextDelta(text_delta);
	// actual expand
	expanded_rect.mBottom -= updated_text_delta;

	LLRect text_box_rect = mTextBox->getRect();

	// check if we need to show scrollbar
	if(text_delta != updated_text_delta)
	{
		static LLUICachedControl<S32> scrollbar_size ("UIScrollbarSize", 0);

		// disable horizontal scrollbar
		text_box_rect.mRight -= scrollbar_size;

		// text box size has changed - redo text wrap
		// Should be handled automatically in reshape() below. JC
		//mTextBox->setWrappedText(mText, text_box_rect.getWidth());

		// recalculate text delta since text wrap changed text height
		text_delta = mTextBox->getVerticalTextDelta() + mTextBox->getVPad() * 2;
	}

	// expand text
	text_box_rect.mBottom -= text_delta;
	mTextBox->reshape(text_box_rect.getWidth(), text_box_rect.getHeight());
	mTextBox->setRect(text_box_rect);

	// expand text box
	localRectToOtherView(expanded_rect, &expanded_screen_rect, getParent());
	reshape(expanded_screen_rect.getWidth(), expanded_screen_rect.getHeight(), FALSE);
	setRect(expanded_screen_rect);

	setFocus(TRUE);
	// this lets us receive top_lost event(needed to collapse text box)
	// it also draws text box above all other ui elements
	gViewerWindow->addPopup(this);

	mExpanded = true;
}