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


C++ BListView::CountItems方法代码示例

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


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

示例1: Window

// Stuff we can only do when the main view is attached to a window
void
OutputFormatView::AttachedToWindow()
{
	// Get the window and lock it
	the_window = Window();
	the_window->Lock();

	// Set some size limits on the window
	the_window->SetSizeLimits(
		200.0,
		32767.0,
		Bounds().Height() - scroll_view->Bounds().Height() + 50.0,
		32767.0);
	// Set the target for messages sent to this view
	list_view->SetTarget(this);
	the_button->SetTarget(this);

	// Make the list view the keyboard focus
	list_view->MakeFocus();

	// Select the first item in the list,
	// and make its config view show up
	if (list_view->CountItems() > 0)
		list_view->Select(0);
	else
		the_button->SetEnabled(false);

	// Unlock the window
	the_window->Unlock();

	// Call the base class
	BView::AttachedToWindow();
}
开发者ID:HaikuArchives,项目名称:Butterfly,代码行数:34,代码来源:OutputFormatWindow.cpp

示例2: AddItem

/**
 *	@brief	Adds one item to the control.
 *	@param[in]	text	item text.
 *	@param[in]	data	associated data of adding item.
 *	@return	the index of added item.
 */
SInt32 BeListViewAdapter::AddItem(ConstAStr text, void* data)
{
	BeGenericDataStringItem* listItem = new BeGenericDataStringItem(text);
	listItem->SetItemData(data);
	
	BListView* listView = getListView();
	listView->AddItem(listItem);
	return listView->CountItems() - 1;
}
开发者ID:HaikuArchives,项目名称:CoveredCalc,代码行数:15,代码来源:BeListViewAdapter.cpp

示例3: RemoveAllItem

/**
 *	@brief	Removes all item from the control.
 */
void BeListViewAdapter::RemoveAllItem()
{
	BListView* listView = getListView();
	int32 count = listView->CountItems();
	int32 index;
	for (index = count - 1; index >= 0; index--)
	{
		BListItem* listItem = listView->RemoveItem(index);
		if (NULL != listItem)
		{
			delete listItem;
		}
	}
}
开发者ID:HaikuArchives,项目名称:CoveredCalc,代码行数:17,代码来源:BeListViewAdapter.cpp

示例4: Enable

/**
 *	@brief	Makes the control enabled or disabled.
 *	@param[in]	doEnable	true to enable the control, or false to disable the control.
 */
void BeListViewAdapter::Enable(bool doEnable)
{
	BListView* listView = getListView();
	int32 count = listView->CountItems();
	int32 index;
	for (index = 0; index < count; index++)
	{
		BListItem* listItem = listView->ItemAt(index);
		listItem->SetEnabled(doEnable);
	}
	listView->LockLooper();
	listView->Invalidate();
	listView->UnlockLooper();
	
	isEnabled = doEnable;
}
开发者ID:HaikuArchives,项目名称:CoveredCalc,代码行数:20,代码来源:BeListViewAdapter.cpp

示例5: FixupScrollbars

void MainView::FixupScrollbars()
{
	return;
	
	BRect bounds=(Bounds()).InsetBySelf(5, 5);
	bounds.right -= B_V_SCROLL_BAR_WIDTH;
	bounds.bottom -= B_H_SCROLL_BAR_HEIGHT;
	BScrollBar *sb;
	BListView* listView = (BListView*)this->FindView("list");
	float ratio=1, realRectWidth=1, realRectHeight=1;
	if (!listView || !scrollView) { return; }

	listView->GetPreferredSize(&realRectWidth, &realRectHeight);
	
	realRectHeight = listView->CountItems() * 18;
	realRectWidth += 15 + B_V_SCROLL_BAR_WIDTH;
	
	sb = scrollView->ScrollBar(B_HORIZONTAL);
	if (sb) {
		ratio = bounds.Width() / (float)realRectWidth;		

		sb->SetRange(0, realRectWidth-bounds.Width());	
		if (ratio >= 1) {
			sb->SetProportion(1);
		} else {
			sb->SetProportion(ratio);
		}
	}

	sb = scrollView->ScrollBar(B_VERTICAL);
	if (sb) {
		ratio = bounds.Height() / (float)realRectHeight;
		
		sb->SetRange(0, realRectHeight+2);
		if (ratio >= 1) {
			sb->SetProportion(1);
		} else {
			sb->SetProportion(ratio);
		}
	}
}
开发者ID:BackupTheBerlios,项目名称:haiku-pim-svn,代码行数:41,代码来源:clsMainWindow.cpp

示例6: str

status_t
PListView::GetProperty(const char *name, PValue *value, const int32 &index) const
{
	if (!name || !value)
		return B_ERROR;
	
	BString str(name);
	PProperty *prop = FindProperty(name,index);
	if (!prop)
		return B_NAME_NOT_FOUND;
	
	BListView *backend = (BListView*)fView;

	if (backend->Window())
		backend->Window()->Lock();

	if (str.ICompare("PreferredWidth") == 0)
	{
		if (backend->CountItems() == 0)
			((FloatProperty*)prop)->SetValue(100);
		else
		{
			float pw, ph;
			backend->GetPreferredSize(&pw, &ph);
			if (pw < 10)
				pw = 100;
			if (ph < 10)
				ph = 30;
			((FloatProperty*)prop)->SetValue(pw);
		}
	}
	else if (str.ICompare("ItemCount") == 0)
		((IntProperty*)prop)->SetValue(backend->CountItems());
	else if (str.ICompare("SelectionMessage") == 0)
		((IntProperty*)prop)->SetValue(backend->SelectionCommand());
	else if (str.ICompare("PreferredHeight") == 0)
	{
		if (backend->CountItems() == 0)
			((FloatProperty*)prop)->SetValue(30);
		else
		{
			float pw, ph;
			backend->GetPreferredSize(&pw, &ph);
			if (pw < 10)
				pw = 100;
			if (ph < 10)
				ph = 30;
			((FloatProperty*)prop)->SetValue(ph);
		}
	}
	else if (str.ICompare("InvocationMessage") == 0)
		((IntProperty*)prop)->SetValue(backend->InvocationCommand());
	else if (str.ICompare("SelectionType") == 0)
		((EnumProperty*)prop)->SetValue(backend->ListType());
	else
	{
		if (backend->Window())
			backend->Window()->Unlock();

		return PView::GetProperty(name, value, index);
	}

	if (backend->Window())
		backend->Window()->Unlock();

	return prop->GetValue(value);
}
开发者ID:HaikuArchives,项目名称:PDesigner,代码行数:67,代码来源:PListView.cpp

示例7: iupdrvListGetCount

int iupdrvListGetCount(Ihandle* ih)
{
  BListView* listview = (BListView*)ih->handle;
  return listview->CountItems();
}
开发者ID:DavidPhillipOster,项目名称:IupCocoa,代码行数:5,代码来源:iuphaiku_list.cpp

示例8: GetCount

/**
 *	@brief	Returns item count in the control.
 *	@return	item count.
 */
SInt32 BeListViewAdapter::GetCount()
{
	BListView* listView = getListView();
	return listView->CountItems();
}
开发者ID:HaikuArchives,项目名称:CoveredCalc,代码行数:9,代码来源:BeListViewAdapter.cpp

示例9: BMessage


//.........这里部分代码省略.........
		BAlert* alert = new BAlert("Error",
			B_TRANSLATE("Unable to find the available languages! You can't "
				"use this preflet!"),
			B_TRANSLATE("OK"), NULL, NULL,
			B_WIDTH_AS_USUAL, B_OFFSET_SPACING, B_STOP_ALERT);
		alert->Go();
	}

	// Second list: active languages
	fPreferredListView = new LanguageListView("preferred",
		B_MULTIPLE_SELECTION_LIST);
	BScrollView* scrollViewEnabled = new BScrollView("scroller",
		fPreferredListView, B_WILL_DRAW | B_FRAME_EVENTS, false, true);

	fPreferredListView->SetInvocationMessage(
		new BMessage(kMsgPreferredLanguageInvoked));
	fPreferredListView->SetDeleteMessage(
		new BMessage(kMsgPreferredLanguageDeleted));
	fPreferredListView->SetDragMessage(
		new BMessage(kMsgPreferredLanguageDragged));

	BLayoutBuilder::Group<>(languageTab)
		.AddGroup(B_VERTICAL, spacing)
			.Add(new BStringView("", B_TRANSLATE("Available languages")))
			.Add(scrollView)
			.End()
		.AddGroup(B_VERTICAL, spacing)
			.Add(new BStringView("", B_TRANSLATE("Preferred languages")))
			.Add(scrollViewEnabled)
			.End()
		.SetInsets(spacing, spacing, spacing, spacing);

	BView* countryTab = new BView(B_TRANSLATE("Country"), B_WILL_DRAW);
	countryTab->SetLayout(new BGroupLayout(B_VERTICAL, 0));

	BListView* listView = new BListView("country", B_SINGLE_SELECTION_LIST);
	scrollView = new BScrollView("scroller", listView,
		B_WILL_DRAW | B_FRAME_EVENTS, false, true);
	listView->SetSelectionMessage(new BMessage(kMsgCountrySelection));

	// get all available countries from ICU
	// Use DateFormat::getAvailableLocale so we get only the one we can
	// use. Maybe check the NumberFormat one and see if there is more.
	int32_t localeCount;
	const Locale* currentLocale = Locale::getAvailableLocales(localeCount);

	for (int index = 0; index < localeCount; index++) {
		UnicodeString countryFullName;
		BString string;
		BStringByteSink sink(&string);
		currentLocale[index].getDisplayName(countryFullName);
		countryFullName.toUTF8(sink);

		LanguageListItem* item
			= new LanguageListItem(string, currentLocale[index].getName(),
				NULL);
		listView->AddItem(item);
		if (!strcmp(currentLocale[index].getName(), defaultCountry->Code()))
			listView->Select(listView->CountItems() - 1);
	}

	// TODO: find a real solution intead of this hack
	listView->SetExplicitMinSize(
		BSize(25 * be_plain_font->Size(), B_SIZE_UNSET));

	fFormatView = new FormatView(defaultCountry);

	countryTab->AddChild(BLayoutBuilder::Group<>(B_HORIZONTAL, spacing)
		.AddGroup(B_VERTICAL, 3)
			.Add(scrollView)
			.End()
		.Add(fFormatView)
		.SetInsets(spacing, spacing, spacing, spacing));

	listView->ScrollToSelection();

	tabView->AddTab(languageTab);
	tabView->AddTab(countryTab);

	BButton* button = new BButton(B_TRANSLATE("Defaults"),
		new BMessage(kMsgDefaults));

	fRevertButton = new BButton(B_TRANSLATE("Revert"),
		new BMessage(kMsgRevert));
	fRevertButton->SetEnabled(false);

	BLayoutBuilder::Group<>(this, B_VERTICAL, spacing)
		.Add(tabView)
		.AddGroup(B_HORIZONTAL, spacing)
			.Add(button)
			.Add(fRevertButton)
			.AddGlue()
			.End()
		.SetInsets(spacing, spacing, spacing, spacing)
		.End();

	_UpdatePreferredFromLocaleRoster();
	SettingsReverted();
	CenterOnScreen();
}
开发者ID:mariuz,项目名称:haiku,代码行数:101,代码来源:LocaleWindow.cpp

示例10:

// Handle messages to the main view
void
OutputFormatView::MessageReceived(BMessage *msg)
{
	int32 item_index;
	const char *info_lines[3];

	switch (msg->what)
	{
		case ITEM_SELECTED:
			if (msg->FindInt32("index", &item_index) == B_OK &&
			    item_index >= 0 &&
			    item_index < list_view->CountItems())
			{
				// Store the currently selected item
				// in the class member 'index'
				index = item_index;
				// Update the info view and config view
				int32 outVersion;
				the_roster->GetTranslatorInfo(
					output_list[item_index].translator,
					&name_line,
					&info_line,
					&outVersion);
				int32 ver = outVersion / 100;
				int32 rev1 = (outVersion % 100) / 10;
				int32 rev2 = outVersion % 10;
				sprintf(version_line, "Version %ld.%ld.%ld", ver, rev1, rev2);
				info_lines[0] = name_line;
				info_lines[1] = info_line;
				info_lines[2] = version_line;
				info_view->SetInfoLines(info_lines);
				AddConfigView();
			}
			else
			{
				// Reselect the original item
				if (index >= 0)
					list_view->Select(index);
			}
			break;

		case INVOKE_LIST:
		{
			// The main button was pressed
			// Find out which item is selected, and invoke it
			int32 item_count = list_view->CountItems();
			for (int32 i = 0; i < item_count; ++i)
			{
				if (list_view->IsItemSelected(i))
				{
					list_view->Invoke();
					break;
				}
			}
			break;
		}
		case SEND_MESSAGE:
			// An output format has been selected
			if (!message_sent &&
			    msg->FindInt32("index", &item_index) == B_OK &&
			    item_index >= 0 &&
			    item_index < list_view->CountItems())
			{
				// Get the message from the invoker
				BMessage *the_message=selected_invoker->Message();
				

				// Add some info about the selected output format to it
				the_message->AddInt32("translator", output_list[item_index].translator);
				the_message->AddInt32("type", output_list[item_index].type);

				// Send the message
				selected_invoker->Invoke(the_message);
				message_sent = true;
				the_window->PostMessage(MESSAGE_SENT);
			}
			break;

		default:
			BView::MessageReceived(msg);
			break;
	}
}
开发者ID:HaikuArchives,项目名称:Butterfly,代码行数:84,代码来源:OutputFormatWindow.cpp


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