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


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

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


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

示例1: BListView

AsciiWindow::AsciiWindow(void)
	:
	DWindow(BRect(0.0f, 0.0f, kWindowWidth, kWindowHeight),
		B_TRANSLATE("ASCII table"), B_TITLED_WINDOW, B_AUTO_UPDATE_SIZE_LIMITS),
	fIsZoomed(false),
	fLastFrame(Frame())
{
	BListView* listView = new BListView("listView", B_MULTIPLE_SELECTION_LIST,
		B_WILL_DRAW);
	BScrollView* listScrollView = new BScrollView("scrollView", listView, 0,
		false, true, B_NO_BORDER);

	listView->SetFont(be_fixed_font);
	listView->AddItem(new BStringItem(B_TRANSLATE("  Dec  Hex  Oct  Code  Description")));
	listView->AddItem(new BStringItem(""));

	for (int i = 0; i < 128; i++) {
		char* row;
		asprintf(&row, "  %3d   %2x  %3o   %3s  %s", i, i, i,
			sAsciiTable[i].code, sAsciiTable[i].description.String());
		listView->AddItem(new BStringItem(row));
		free(row);
	}

	BLayoutBuilder::Group<>(this, B_VERTICAL)
		.Add(listScrollView)
		.SetInsets(-1)
		.End();

	CenterOnScreen();
}
开发者ID:humdingerb,项目名称:Paladin,代码行数:31,代码来源:AsciiWindow.cpp

示例2: bmpRect

HostInfoView::HostInfoView(BRect rect, const char *name, uint32 ipAddr)
	: BView(rect, "HostInfoView", B_FOLLOW_ALL, B_WILL_DRAW)
{
	address = ipAddr;

	hostInfo.cpus = 0;
	thread_id infoThread = spawn_thread(getHostInfo, "Get Host Info", B_NORMAL_PRIORITY, this);
	resume_thread(infoThread);

	rgb_color gray = ui_color(B_PANEL_BACKGROUND_COLOR);
	SetViewColor(gray);

	BRect bmpRect(0.0, 0.0, 31.0, 31.0);
	icon = new BBitmap(bmpRect, B_CMAP8);

	BMimeType mime("application/x-vnd.BeServed-fileserver");
	mime.GetIcon(icon, B_LARGE_ICON);

	BRect r(40, 55, 230, 120);
	BListView *aliasList = new BListView(r, "Aliases", B_SINGLE_SELECTION_LIST);
	AddChild(new BScrollView("ScrollAliases", aliasList, B_FOLLOW_LEFT | B_FOLLOW_TOP,
		0, false, true));

	r.top = 145;
	r.bottom = 210;
	BListView *addressList = new BListView(r, "Addresses", B_SINGLE_SELECTION_LIST);
	AddChild(new BScrollView("ScrollAddresses", addressList, B_FOLLOW_LEFT | B_FOLLOW_TOP,
		0, false, true));

	r.top = 275;
	r.bottom = 305;
	r.left = 38;
	r.right = 245;
	status = new BStatusBar(r, "Connections");
	status->SetBarHeight(13.0);
	AddChild(status);

	ent = gethostbyaddr((char *) &ipAddr, sizeof(ipAddr), AF_INET);
	if (ent)
	{
		char buf[50];
		int i;
		for (i = 0; ent->h_aliases[i] != 0; i++)
			aliasList->AddItem(new BStringItem(ent->h_aliases[i]));

		for (i = 0; ent->h_addr_list[i] != 0; i++)
		{
			sprintf(buf, "%d.%d.%d.%d", (uint8) ent->h_addr_list[i][0], (uint8) ent->h_addr_list[i][1],
				(uint8) ent->h_addr_list[i][2], (uint8) ent->h_addr_list[i][3]);
			addressList->AddItem(new BStringItem(buf));
		}
	}
}
开发者ID:HaikuArchives,项目名称:BeServed,代码行数:53,代码来源:MyNetView.cpp

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

示例4: BStringItem

int32_t
PListViewAddItem(void *pobject, void *in, void *out, void *extraData)
{
	if (!pobject || !in || !out)
		return B_ERROR;
	
	PView *parent = static_cast<PView*>(pobject);
	if (!parent)
		return B_BAD_TYPE;
	
	BListView *backend = (BListView*)parent->GetView();
	
	PArgs *args = static_cast<PArgs*>(in), *outArgs = static_cast<PArgs*>(out);
	BString label;
	if (args->FindString("label", &label) != B_OK)
		label = "";
	
	int32 index;
	if (args->FindInt32("index", &index) != B_OK)
		index = -1;
	
	if (backend->Window())
		backend->Window()->Lock();
	
	bool outValue;
	BStringItem *item = new BStringItem(label.String());
	if (index >= 0)
		outValue = backend->AddItem(item);
	else
		outValue = backend->AddItem(item, index);
	
	if (backend->Window())
		backend->Window()->Unlock();
	
	outArgs->MakeEmpty();
	outArgs->AddBool("value", outValue);
	
	return B_OK;
}
开发者ID:HaikuArchives,项目名称:PDesigner,代码行数:39,代码来源:PListView.cpp

示例5: iupdrvListAppendItem

void iupdrvListAppendItem(Ihandle* ih, const char* value)
{
  BView* view = (BView*)ih->handle;

  BMenuField* menu = dynamic_cast<BMenuField*>(view);
  if(menu)
  {
    menu->Menu()->AddItem(new BMenuItem(value, NULL));
	return;
  }

  BListView* listview = iuphaikuGetListView(view);

  if(listview)
  {
    BListItem* item = new BStringItem(value);
	listview->LockLooper();
    listview->AddItem(item);
	listview->UnlockLooper();
  } else {
    fprintf(stderr, "View hierarchy problem\n");
  }

}
开发者ID:DavidPhillipOster,项目名称:IupCocoa,代码行数:24,代码来源:iuphaiku_list.cpp

示例6: app

int
main(int argc, char** argv)
{
	BApplication app("application/x-vnd.antares-look");

	BWindow* window = new Window(BRect(50, 50, 100, 100),
		"Look at these pretty controls!", B_TITLED_WINDOW,
		B_ASYNCHRONOUS_CONTROLS | B_AUTO_UPDATE_SIZE_LIMITS
			| B_QUIT_ON_WINDOW_CLOSE);

	window->SetLayout(new BGroupLayout(B_HORIZONTAL));

	// create some controls

	// BListView
	BListView* listView = new BListView();
	for (int32 i = 0; i < 20; i++) {
		BString itemLabel("List item ");
		itemLabel << i + 1;
		listView->AddItem(new BStringItem(itemLabel.String()));
	}
	BScrollView* scrollView = new BScrollView("scroller", listView, 0,
		true, true);
	scrollView->SetExplicitMinSize(BSize(300, 140));

	// BColumnListView
	BColumnListView* columnListView = new BColumnListView("clv", 0,
		B_FANCY_BORDER);
//	for (int32 i = 0; i < 20; i++) {
//		BString itemLabel("List Item ");
//		itemLabel << i + 1;
//		columnListView->AddItem(new BStringItem(itemLabel.String()));
//	}


	BGridView* controls = new BGridView(kInset, kInset);
	BGridLayout* layout = controls->GridLayout();
	controls->SetExplicitMaxSize(BSize(B_SIZE_UNLIMITED, B_SIZE_UNLIMITED));

	int32 row = 0;
	add_controls<BButton>(layout, row);
	add_controls<BCheckBox>(layout, row);
	add_controls<BRadioButton>(layout, row);
	add_menu_fields(layout, row);
	add_text_controls(layout, row);
	add_sliders(layout, row);
	add_status_bars(layout, row);

	BColorControl* colorControl = new BColorControl(B_ORIGIN, B_CELLS_32x8,
		8.0f, "color control");
	layout->AddView(colorControl, 0, row, 4);

	BTabView* tabView = new BTabView("tab view", B_WIDTH_FROM_WIDEST);
	BView* content = BGroupLayoutBuilder(B_VERTICAL, kInset)
		.Add(scrollView)
		.Add(columnListView)
		.Add(controls)
		.SetInsets(kInset, kInset, kInset, kInset);

	content->SetName("Tab 1");

	tabView->AddTab(content);
	BView* tab2 = new BView("Tab 2", 0);
	tab2->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
	tabView->AddTab(tab2);
	tabView->AddTab(new BView("Tab 3", 0));

	BMenuBar* menuBar = new BMenuBar("menu bar");
	BMenu* menu = new BMenu("File");
	menu->AddItem(new BMenuItem("Test Open BFilePanel",
		new BMessage(MSG_TEST_OPEN_FILE_PANEL)));
	menu->AddItem(new BMenuItem("Test Save BFilePanel",
		new BMessage(MSG_TEST_SAVE_FILE_PANEL)));
	menu->AddItem(new BMenuItem("Click me!", NULL));
	menu->AddItem(new BMenuItem("Another option", NULL));
	menu->AddSeparatorItem();
	menu->AddItem(new BMenuItem("Quit", new BMessage(B_QUIT_REQUESTED)));
	menuBar->AddItem(menu);
	menu = new BMenu("Edit");
	menu->SetEnabled(false);
	menu->AddItem(new BMenuItem("Cut", NULL));
	menu->AddItem(new BMenuItem("Copy", NULL));
	menu->AddSeparatorItem();
	menu->AddItem(new BMenuItem("Past", NULL));
	menuBar->AddItem(menu);
	menu = new BMenu("One Item");
	menu->AddItem(new BMenuItem("Only", NULL));
	menuBar->AddItem(menu);
	menu = new BMenu("Sub Menu");
	BMenu* subMenu = new BMenu("Click me");
	subMenu->AddItem(new BMenuItem("Either", NULL));
	subMenu->AddItem(new BMenuItem("Or", NULL));
	subMenu->SetRadioMode(true);
	menu->AddItem(subMenu);
	menuBar->AddItem(menu);

	BButton* okButton = new BButton("OK", new BMessage(B_QUIT_REQUESTED));

	window->AddChild(BGroupLayoutBuilder(B_VERTICAL)
		.Add(menuBar)
//.........这里部分代码省略.........
开发者ID:mmanley,项目名称:Antares,代码行数:101,代码来源:Look.cpp

示例7: InitWindow

// ResourceUsageWindow::InitWindow -- Initialization Commands here
void ResourceUsageWindow::InitWindow(BList &list)
{
	BRect rtab = Bounds();
	BRect rlist = Bounds();
	rtab.top += 10;
	rlist.top += 10;
	rlist.left += 12;
	rlist.right -= 15 + B_V_SCROLL_BAR_WIDTH;
	rlist.bottom -= 47;

	// Create the TabView and Tabs
	BTabView *tabView = new BTabView(rtab,"resource_usage_tabview");
	tabView->SetViewUIColor(B_PANEL_BACKGROUND_COLOR);
	
	rtab = tabView->Bounds();
	rtab.InsetBy(5,5);
	
	// Create the ListViews
	BListView *IRQListView = new BListView(rlist, "IRQListView",
		B_SINGLE_SELECTION_LIST, B_FOLLOW_LEFT | B_FOLLOW_TOP,
		B_WILL_DRAW | B_NAVIGABLE);
	BListView *DMAListView = new BListView(rlist, "DMAListView",
		B_SINGLE_SELECTION_LIST, B_FOLLOW_LEFT | B_FOLLOW_TOP,
		B_WILL_DRAW | B_NAVIGABLE);
	BListView *IORangeListView = new BListView(rlist, "IORangeListView",
		B_SINGLE_SELECTION_LIST, B_FOLLOW_LEFT | B_FOLLOW_TOP,
		B_WILL_DRAW | B_NAVIGABLE);
	BListView *memoryListView = new BListView(rlist, "memoryListView",
		B_SINGLE_SELECTION_LIST, B_FOLLOW_LEFT | B_FOLLOW_TOP,
		B_WILL_DRAW | B_NAVIGABLE);
	
	BScrollView *IRQScrollView = new BScrollView("scroll_list1", IRQListView,
		B_FOLLOW_LEFT|B_FOLLOW_TOP, 0, false, true, B_FANCY_BORDER);
	BScrollView *DMAScrollView = new BScrollView("scroll_list2", DMAListView,
		B_FOLLOW_LEFT|B_FOLLOW_TOP, 0, false, true, B_FANCY_BORDER);
	BScrollView *IORangeScrollView = new BScrollView("scroll_list3",
		IORangeListView, B_FOLLOW_LEFT|B_FOLLOW_TOP, 0, false, true,
		B_FANCY_BORDER);
	BScrollView *memoryScrollView = new BScrollView("scroll_list4",
		memoryListView, B_FOLLOW_LEFT|B_FOLLOW_TOP, 0, false, true,
		B_FANCY_BORDER);
	
	BTab *tab = new BTab();
	tabView->AddTab(IRQScrollView, tab);
	tab->SetLabel(B_TRANSLATE("IRQ"));
	tab = new BTab();
	tabView->AddTab(DMAScrollView, tab);
	tab->SetLabel(B_TRANSLATE("DMA"));
	tab = new BTab();
	tabView->AddTab(IORangeScrollView, tab);
	tab->SetLabel(B_TRANSLATE("IO Range"));
	tab = new BTab();
	tabView->AddTab(memoryScrollView, tab);
	tab->SetLabel(B_TRANSLATE("Memory Range"));
	
	{
		uint32 mask = 1;
		
		for (int i=0;i<16;mask<<=1,i++) {
			bool first = true;
			
			for (int32 j=0; j<list.CountItems(); j++) {
				DevicesInfo *deviceInfo = (DevicesInfo *)list.ItemAt(j);
				struct device_configuration *current = deviceInfo->GetCurrent();
				resource_descriptor r;
				
				int32 num = count_resource_descriptors_of_type(current,
					B_IRQ_RESOURCE);
				
				for (int32 k=0;k<num;k++) {
					get_nth_resource_descriptor_of_type(current, k, B_IRQ_RESOURCE,
							&r, sizeof(resource_descriptor));
					
					if (mask & r.d.m.mask) {
						IRQListView->AddItem(new IRQDMAItem(first ? i : -1,
							deviceInfo->GetCardName()));
						first = false;
					}
				}
			}
			
			if (first) {
				IRQListView->AddItem(new IRQDMAItem(i, ""));
			}
		}
	}
	
	{
		uint32 mask = 1;
		
		for (int i=0;i<8;mask<<=1,i++) {
			bool first = true;
			
			for (int32 j=0; j<list.CountItems(); j++) {
				DevicesInfo *deviceInfo = (DevicesInfo *)list.ItemAt(j);
				struct device_configuration *current = deviceInfo->GetCurrent();
				resource_descriptor r;
				
				int32 num = count_resource_descriptors_of_type(current,
//.........这里部分代码省略.........
开发者ID:AmirAbrams,项目名称:haiku,代码行数:101,代码来源:ResourceUsageWindow.cpp

示例8: BMessage

LocaleWindow::LocaleWindow()
	:
	BWindow(BRect(0, 0, 0, 0), "Locale", B_TITLED_WINDOW, B_QUIT_ON_WINDOW_CLOSE
		| B_ASYNCHRONOUS_CONTROLS | B_AUTO_UPDATE_SIZE_LIMITS)
{
	BCountry* defaultCountry;
	be_locale_roster->GetDefaultCountry(&defaultCountry);

	SetLayout(new BGroupLayout(B_HORIZONTAL));

	float spacing = be_control_look->DefaultItemSpacing();

	BTabView* tabView = new BTabView("tabview");
	BGroupView* languageTab = new BGroupView(B_TRANSLATE("Language"),
		B_HORIZONTAL, spacing);

	// first list: available languages
	fLanguageListView = new LanguageListView("available",
		B_MULTIPLE_SELECTION_LIST);
	BScrollView* scrollView = new BScrollView("scroller", fLanguageListView,
		B_WILL_DRAW | B_FRAME_EVENTS, false, true);

	fLanguageListView->SetInvocationMessage(new BMessage(kMsgLanguageInvoked));
	fLanguageListView->SetDragMessage(new BMessage(kMsgLanguageDragged));

	// Fill the language list from the LocaleRoster data
	BMessage installedLanguages;
	if (be_locale_roster->GetInstalledLanguages(&installedLanguages) == B_OK) {
		BString currentID;
		LanguageListItem* lastAddedCountryItem = NULL;

		for (int i = 0; installedLanguages.FindString("langs", i, &currentID)
				== B_OK; i++) {
			// Now get an human-readable, localized name for each language
			BLanguage* currentLanguage;
			be_locale_roster->GetLanguage(currentID.String(),
				&currentLanguage);

			BString name;
			currentLanguage->GetName(name);

			// TODO: as long as the app_server doesn't support font overlays,
			// use the translated name if problematic characters are used...
			const char* string = name.String();
			while (uint32 code = BUnicodeChar::FromUTF8(&string)) {
				if (code > 1424) {
					currentLanguage->GetTranslatedName(name);
					break;
				}
			}

			LanguageListItem* item = new LanguageListItem(name,
				currentID.String(), currentLanguage->Code());
			if (currentLanguage->IsCountrySpecific()
				&& lastAddedCountryItem != NULL
				&& lastAddedCountryItem->Code() == item->Code()) {
				fLanguageListView->AddUnder(item, lastAddedCountryItem);
			} else {
				// This is a language variant, add it at top-level
				fLanguageListView->AddItem(item);
				if (!currentLanguage->IsCountrySpecific()) {
					item->SetExpanded(false);
					lastAddedCountryItem = item;
				}
			}

			delete currentLanguage;
		}

		fLanguageListView->FullListSortItems(compare_typed_list_items);
	} else {
		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)
//.........这里部分代码省略.........
开发者ID:mariuz,项目名称:haiku,代码行数:101,代码来源:LocaleWindow.cpp


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