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


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

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


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

示例1: invMsg

int32_t
PListViewInvoke(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);
	int32 what;
	if (args->FindInt32("message", &what) != B_OK)
		what = -1;
	
	if (backend->Window())
		backend->Window()->Lock();
	
	if (what >= 0)
	{
		BMessage invMsg(what);
		backend->Invoke(&invMsg);
	}
	else	
		backend->Invoke();
	
	if (backend->Window())
		backend->Window()->Unlock();
	
	return B_OK;
}
开发者ID:HaikuArchives,项目名称:PDesigner,代码行数:33,代码来源:PListView.cpp

示例2:

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