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


C++ BListItem类代码示例

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


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

示例1: CountItems

void ArpOutlineListView::ComputeDimens(ArpDimens& cur_dimens)
{
	float min_w=0, min_h=0;
	float pref_w=0, pref_h=0;
	
	int32 num = CountItems();
	int32 max_num = 4;
	for( int32 i=0; i<num; i++ ) {
		BListItem* item = ItemAt(i);
		if( item ) {
			item->Update(this,BasicFont());
			float w = item->Width();
			float h = item->Height();
			min_h = max(min_h,h);
			pref_w = max(pref_w,w);
			if( max_num > 0 ) pref_h += h;
			max_num--;
		}
	}
	pref_h+=2;
	float fw = BasicFont()->StringWidth("WWWW");
	font_height fhs;
	BasicFont()->GetHeight(&fhs);
	float fh = fhs.ascent+fhs.descent+fhs.leading;
	min_w = max(min_w,fw);
	min_h = max(min_h,fh);
	pref_w = max(pref_w,min_w);
	pref_h = max(pref_h,min_h);
	
	cur_dimens.X().SetTo(0, min_w, pref_w, ArpAnySize, 0);
	cur_dimens.Y().SetTo(0, min_h, pref_h, ArpAnySize, 0);
}
开发者ID:HaikuArchives,项目名称:Sequitur,代码行数:32,代码来源:ViewStubs.cpp

示例2: 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

示例3: 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

示例4: FullListCountItems

BList*
BOutlineListView::_BuildTree(BListItem* underItem, int32& fullIndex)
{
	int32 fullCount = FullListCountItems();
	uint32 level = underItem != NULL ? underItem->OutlineLevel() + 1 : 0;
	BList* list = new BList;
	if (underItem != NULL)
		underItem->fTemporaryList = list;

	while (fullIndex < fullCount) {
		BListItem* item = FullListItemAt(fullIndex);

		// If we jump out of the subtree, break out
		if (item->fLevel < level)
			break;

		// If the level matches, put them into the list
		// (we handle the case of a missing sublevel gracefully)
		list->AddItem(item);
		fullIndex++;

		if (item->HasSubitems()) {
			// we're going deeper
			_BuildTree(item, fullIndex);
		}
	}

	return list;
}
开发者ID:,项目名称:,代码行数:29,代码来源:

示例5: 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

示例6: while

status_t
BOutlineListView::Archive(BMessage* archive, bool deep) const
{
	// Note: We can't call the BListView Archive function here, as we are also
	// interested in subitems BOutlineListView can have. They are even stored
	// with a different field name (_l_full_items vs. _l_items).

	status_t status = BView::Archive(archive, deep);
	if (status != B_OK)
		return status;

	status = archive->AddInt32("_lv_type", fListType);
	if (status == B_OK && deep) {
		int32 i = 0;
		BListItem* item = NULL;
		while ((item = static_cast<BListItem*>(fFullList.ItemAt(i++)))) {
			BMessage subData;
			status = item->Archive(&subData, true);
			if (status >= B_OK)
				status = archive->AddMessage("_l_full_items", &subData);

			if (status < B_OK)
				break;
		}
	}

	if (status >= B_OK && InvocationMessage() != NULL)
		status = archive->AddMessage("_msg", InvocationMessage());

	if (status == B_OK && fSelectMessage != NULL)
		status = archive->AddMessage("_2nd_msg", fSelectMessage);

	return status;
}
开发者ID:,项目名称:,代码行数:34,代码来源:

示例7: IsExpanded

bool ColumnListView::IsExpanded(int32 fullListIndex) const
{
	BListItem* TheItem = (BListItem*)fFullItemList.ItemAt(fullListIndex);
	if(TheItem)
		return TheItem->IsExpanded();
	else
		return false;
}
开发者ID:mariuz,项目名称:haiku,代码行数:8,代码来源:ColumnListView.cpp

示例8: CountItems

int32 MyListView::GetMaxPages (BRect printArea)
{
	// assume pages always fit horizontally
	int32 maxItems = CountItems();
	BListItem *item = FirstItem();
	if (item == NULL) return 0;
	return (int32)ceil(maxItems*item->Height()/printArea.Height());
}
开发者ID:,项目名称:,代码行数:8,代码来源:

示例9: TitleItem

BListItem*
NetworkWindow::_CreateItem(const char* label)
{
	BListItem* item = new TitleItem(label);
	item->SetExpanded(true);
	fListView->AddItem(item);
	return item;
}
开发者ID:kodybrown,项目名称:haiku,代码行数:8,代码来源:NetworkWindow.cpp

示例10: FullListItemAt

bool
BOutlineListView::IsExpanded(int32 fullListIndex)
{
	BListItem* item = FullListItemAt(fullListIndex);
	if (!item)
		return false;

	return item->IsExpanded();
}
开发者ID:,项目名称:,代码行数:9,代码来源:

示例11: _GetSubItems

static void
_GetSubItems(BList& sourceList, BList& destList, BListItem* parent, int32 start)
{
	for (int32 i = start; i < sourceList.CountItems(); i++) {
		BListItem* item = (BListItem*)sourceList.ItemAt(i);
		if (item->OutlineLevel() <= parent->OutlineLevel())
			break;
		destList.AddItem(item);
	}
}
开发者ID:,项目名称:,代码行数:10,代码来源:

示例12:

void
MediaWindow::_UpdateListViewMinWidth()
{
	float width = 0;
	for (int32 i = 0; i < fListView->CountItems(); i++) {
		BListItem* item = fListView->ItemAt(i);
		width = max_c(width, item->Width());
	}
	fListView->SetExplicitMinSize(BSize(width, B_SIZE_UNSET));
	fListView->InvalidateLayout();
}
开发者ID:bhanug,项目名称:haiku,代码行数:11,代码来源:MediaWindow.cpp

示例13:

void
BOutlineListView::_DestructTree(BList* tree)
{
	for (int32 index = tree->CountItems(); index-- > 0;) {
		BListItem* item = (BListItem*)tree->ItemAt(index);

		if (item->HasSubitems())
			_DestructTree(item->fTemporaryList);
	}

	delete tree;
}
开发者ID:,项目名称:,代码行数:12,代码来源:

示例14: while

bool BrowseView::NextInList(BOutlineListView *list, const char *nameToSearch, BListItem *afterThis)
{
	myItem = afterThis;
	notYet = (afterThis!=NULL);
	myStr = nameToSearch;
	
	list->FullListDoForEach(&iterate,(void*)this);
	
	if ((myItem == NULL) || (myItem == afterThis))
	{		// un item suivant n'a pas été trouvé
		if (afterThis == NULL)
			// ben ya vraiment rien
			return false;
		
			// on peut peut être en trouver un avant
		myItem = NULL;
		list->FullListDoForEach(&iterate,(void*)this);
		
		if ((myItem == NULL) || (myItem == afterThis))
			// ça veut vraiment pas!
			return false;
	}
	
	// on a donc un nouvel item à sélectionner		
	BListItem *iterate = list->Superitem(myItem), *oldIterate = NULL;
	while (iterate != NULL)
	{
		iterate->SetExpanded(true);

		oldIterate = iterate;			
		iterate = list->Superitem(iterate);
	}

	// ce petit truc de Collapse/Expand permet d'être sûr que la outlinelist est mise à jour
	// j'ai fait comme ça parce que BOutlineListView::Expand() ne marche pas sur un item
	// qui n'est pas encore visible. BListItem::SetExpanded marche mais ne met pas à jour
	// l'affichage
	if (oldIterate != NULL)
	{
		list->Collapse(oldIterate);
		list->Expand(oldIterate);
	}
	
	// maintenant l'item devrait être visible
	unsigned int n = list->IndexOf(myItem);
	
	if (n<0)
		return false;	// ben non!
	list->Select(n);
	list->ScrollToSelection();
	return true;
}
开发者ID:mmadia,项目名称:behappy-svn_clone,代码行数:52,代码来源:BrowseView.cpp

示例15: Bounds

BRect
BListView::ItemFrame(int32 index)
{
	BRect frame = Bounds();
	if (index < 0 || index >= CountItems()) {
		frame.top = 0;
		frame.bottom = -1;
	} else {
		BListItem* item = ItemAt(index);
		frame.top = item->Top();
		frame.bottom = item->Bottom();
	}
	return frame;
}
开发者ID:RAZVOR,项目名称:haiku,代码行数:14,代码来源:ListView.cpp


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