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


C++ CountItems函数代码示例

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


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

示例1: CountItems

int32
BListView::_CalcFirstSelected(int32 after)
{
    if (after >= CountItems())
        return -1;

    int32 count = CountItems();
    for (int32 i = after; i < count; i++) {
        if (ItemAt(i)->IsSelected())
            return i;
    }

    return -1;
}
开发者ID:mmuman,项目名称:haiku,代码行数:14,代码来源:ListView.cpp

示例2: Items

	inline bool operator ==(const Selection& other)
		{
			if (other.CountItems() == CountItems()) {
				int32* items = Items();
				int32* otherItems = other.Items();
				for (int32 i = 0; i < CountItems(); i++) {
					if (items[i] != otherItems[i])
						return false;
					items++;
					otherItems++;
				}
				return true;
			} else
				return false;
		}
开发者ID:mariuz,项目名称:haiku,代码行数:15,代码来源:PathManipulator.cpp

示例3: B_BENDIAN_TO_HOST_INT32

//------------------------------------------------------------------------------
void BMessageField::PrintToStream(const char* name) const
{
	int32 type = B_BENDIAN_TO_HOST_INT32(Type());
	printf("    entry %14s, type='%.4s', c=%2ld, ",
		   name, (char*)&type, CountItems());

	for (int32 i = 0; i < CountItems(); ++i)
	{
		if (i)
		{
			printf("                                            ");
		}
		PrintDataItem(i);
	}
}
开发者ID:BackupTheBerlios,项目名称:nemo,代码行数:16,代码来源:MessageField.cpp

示例4: Entered

	virtual void Entered()
	{
		_DeleteItems();

		if (fDirectory != NULL) {
			void* cookie;
			if (fDirectory->Open(&cookie, O_RDONLY) == B_OK) {
				Node* node;
				while (fDirectory->GetNextNode(cookie, &node) == B_OK) {
					BlacklistMenuItem* item = _CreateItem(node);
					node->Release();
					if (item == NULL)
						break;

					AddItem(item);

					item->UpdateBlacklisted();
				}
				fDirectory->Close(cookie);
			}

			SortItems(&BlacklistMenuItem::Less);
		}

		if (CountItems() > 0)
			AddSeparatorItem();
		AddItem(new(nothrow) MenuItem("Return to parent directory"));
	}
开发者ID:SummerSnail2014,项目名称:haiku,代码行数:28,代码来源:menu.cpp

示例5: PushState

void NetListView::FrameResized(float width, float height)
{
	BListView::FrameResized(width, height);
	//Ensure the bevel on the right is drawn properly
	if(width < oldWidth)
		oldWidth = width;
	PushState();
	BRect invalRect(oldWidth, 0, oldWidth, height);
	ConvertFromParent(&invalRect);
	BRegion lineRegion(invalRect);
	ConstrainClippingRegion(&lineRegion);
	Draw(invalRect);
	oldWidth = width;
	PopState();
	
	//Do word wrapping
	BFont curFont;
	GetFont(&curFont);
	float itemWidth = Bounds().Width();
	float wrapWidth = (itemWidth - 6)/curFont.Size();
	for(int itemNum = 0; itemNum < CountItems(); itemNum++)
	{
		NetListItem* item = (NetListItem*)(Items()[itemNum]);
		item->SetWidth(itemWidth);
		item->CalcWordWrap(wrapWidth);
	}
	//DoForEach(UpdateItem, (void*)this);
	Invalidate();
	
	BListView::FrameResized(width, height);
}
开发者ID:thinkpractice,项目名称:bme,代码行数:31,代码来源:NetListView.cpp

示例6: printf

void DraggableListView::MessageReceived(BMessage *message) {
	if (message->what != B_PULSE) {
		printf("DraggableListView:\n");
		message->PrintToStream();
		printf("\n");
	}
	switch(message->what) {
		case SM_DRAG_FILTER: {
			if (accepts_drags) {
				int32 item_count;
				type_code type_found;
				message->GetInfo("filter_name", &type_found, &item_count);
				int32 current_item = 0;
				char* text = NULL;
				int32 filter_id = 0;
				message->FindString("filter_name", current_item, &text);
				// Do add-filter stuff
				BMessage app_msg(SM_ADD_FILTER);
				app_msg.AddString("addon_name", text);
				app_msg.AddInt32("position", CountItems());
				BMessage reply;
				be_app_messenger.SendMessage(&app_msg, &reply);
				reply.FindInt32("filter_id", &filter_id);
				BStringItem *newItem = new FilterItem(text, filter_id);
				AddItem(newItem);
			}
			break;
		}
		default: {
			BListView::MessageReceived(message);
			break;
		}
	}
}
开发者ID:HaikuArchives,项目名称:SoundMangler,代码行数:34,代码来源:DraggableListView.cpp

示例7: RemoveItem

void
NetworkMenu::AttachedToWindow (void)
{
	if (CountItems())
	{
		BMenuItem *item (NULL);
		while ((item = RemoveItem((int32)0)) != NULL)
			delete item;
	}

	BMessage msg;
	BMessage *invoke (NULL);
	for (int32 i = 0; (msg = vision_app->GetNetwork (i)), !msg.HasBool ("error"); i++)
	{
		const char *name = msg.FindString ("name");
		invoke = new BMessage (fMsgConst);
		invoke->AddString ("network", name);
		BMenuItem *item (new BMenuItem(name, invoke));
		AddItem (item);
		if (!vision_app->CheckNetworkValid (name))
			item->SetEnabled (false);
	}
	SetTargetForItems (fTarget.Target(NULL));
	BMenu::AttachedToWindow();
}
开发者ID:jessicah,项目名称:Vision,代码行数:25,代码来源:NetworkMenu.cpp

示例8:

IFWL_ListItem* CFWL_ListBox::CFWL_ListBoxDP::GetItem(IFWL_Widget* pWidget,
                                                     int32_t nIndex) {
  if (nIndex < 0 || nIndex >= CountItems(pWidget))
    return nullptr;

  return m_ItemArray[nIndex].get();
}
开发者ID:endlessm,项目名称:chromium-browser,代码行数:7,代码来源:cfwl_listbox.cpp

示例9: cast_as

/***********************************************************
 * DeleteItem
 ***********************************************************/
void
HListView::DeleteItem(int32 index) {
	HListItem* item = cast_as(RemoveItem(index), HListItem);
	fPointerList.RemoveItem(item);
	delete item;

	HApp* app = cast_as(be_app, HApp);
	bool queue;

	int32 max_transfer;
	app->Prefs()->GetData("queue", &queue);
	app->Prefs()->GetData("max_transfer", &max_transfer);

	if (queue) {
		int32 num_task = max_transfer - CountDownloadingItems();
		if (num_task > 0) {
			int32 count = CountItems();
			HListItem** items = (HListItem**)Items();
			for (int32 i = 0; i < count; i++) {
				item = items[i];
				if (!item->IsStarted() && item->State() != T_FINISHED && item->State() != T_NOTFOUND) {
					item->Start();
					num_task--;
				}
				if (num_task <= 0)
					break;
			}
		}
	}
}
开发者ID:kallisti5,项目名称:beget,代码行数:33,代码来源:HListView.cpp

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

示例11: CountItems

bool
BrowsingHistory::_AddItem(const BrowsingHistoryItem& item, bool internal)
{
	int32 count = CountItems();
	int32 insertionIndex = count;
	for (int32 i = 0; i < count; i++) {
		BrowsingHistoryItem* existingItem
			= reinterpret_cast<BrowsingHistoryItem*>(
			fHistoryItems.ItemAtFast(i));
		if (item.URL() == existingItem->URL()) {
			if (!internal) {
				existingItem->Invoked();
				_SaveSettings();
			}
			return true;
		}
		if (item < *existingItem)
			insertionIndex = i;
	}
	BrowsingHistoryItem* newItem = new(std::nothrow) BrowsingHistoryItem(item);
	if (!newItem || !fHistoryItems.AddItem(newItem, insertionIndex)) {
		delete newItem;
		return false;
	}

	if (!internal) {
		newItem->Invoked();
		_SaveSettings();
	}

	return true;
}
开发者ID:AmirAbrams,项目名称:haiku,代码行数:32,代码来源:BrowsingHistory.cpp

示例12: max_c

void
BListView::_RescanSelection(int32 from, int32 to)
{
	if (from > to) {
		int32 tmp = from;
		from = to;
		to = tmp;
	}

	from = max_c(0, from);
	to = min_c(to, CountItems() - 1);

	if (fAnchorIndex != -1) {
		if (fAnchorIndex == from)
			fAnchorIndex = to;
		else if (fAnchorIndex == to)
			fAnchorIndex = from;
	}

	for (int32 i = from; i <= to; i++) {
		if (ItemAt(i)->IsSelected()) {
			fFirstSelected = i;
			break;
		}
	}

	if (fFirstSelected > from)
		from = fFirstSelected;

	fLastSelected = fFirstSelected;
	for (int32 i = from; i <= to; i++) {
		if (ItemAt(i)->IsSelected())
			fLastSelected = i;
	}
}
开发者ID:RAZVOR,项目名称:haiku,代码行数:35,代码来源:ListView.cpp

示例13: AddListPrivate

bool ColumnListView::AddList(BList* newItems)
{
	if(fHierarchical)
		return AddListPrivate(newItems,fFullItemList.CountItems());
	else
		return AddListPrivate(newItems,CountItems());
}
开发者ID:mariuz,项目名称:haiku,代码行数:7,代码来源:ColumnListView.cpp

示例14: AddItemPrivate

bool ColumnListView::AddItem(CLVListItem* item)
{
	if(fHierarchical)
		return AddItemPrivate(item,fFullItemList.CountItems());
	else
		return AddItemPrivate(item,CountItems());
}
开发者ID:mariuz,项目名称:haiku,代码行数:7,代码来源:ColumnListView.cpp

示例15: lock

int32 QueryMenu::QueryThread()
{
	BAutolock lock(fQueryLock);

	if (!lock.IsLocked())
		return B_ERROR;

	// Begin resolving query
	fCancelQuery = false;
	fQuery->Fetch();

	// Build Menu
	entry_ref ref;
	node_ref node;
	while (fQuery->GetNextRef(&ref) == B_OK && !fCancelQuery)
	{
		BEntry entry(&ref);
		entry.GetNodeRef(&node);
		EntryCreated(ref, node.node);
	}

	// Remove the group separator if there are no groups or no items without groups
	BMenuItem *item;
	if (dynamic_cast<BSeparatorItem *>(item = ItemAt(0)) != NULL)
		RemoveItem(item);
	else if (dynamic_cast<BSeparatorItem *>(item = ItemAt(CountItems() - 1)) != NULL)
		RemoveItem(item);

	return B_OK;
}
开发者ID:HaikuArchives,项目名称:BeMailDaemon,代码行数:30,代码来源:QueryMenu.cpp


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