本文整理汇总了C++中BTranslatorRoster::GetInputFormats方法的典型用法代码示例。如果您正苦于以下问题:C++ BTranslatorRoster::GetInputFormats方法的具体用法?C++ BTranslatorRoster::GetInputFormats怎么用?C++ BTranslatorRoster::GetInputFormats使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BTranslatorRoster
的用法示例。
在下文中一共展示了BTranslatorRoster::GetInputFormats方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: BMessage
status_t
AddTranslationItems(BMenu* intoMenu, uint32 fromType)
{
BTranslatorRoster* use;
char* translatorTypeName;
const char* translatorIdName;
use = BTranslatorRoster::Default();
translatorIdName = "be:translator";
translatorTypeName = (char *)"be:type";
translator_id* ids = NULL;
int32 count = 0;
status_t err = use->GetAllTranslators(&ids, &count);
if (err < B_OK)
return err;
for (int tix = 0; tix < count; tix++) {
const translation_format* formats = NULL;
int32 num_formats = 0;
bool ok = false;
err = use->GetInputFormats(ids[tix], &formats, &num_formats);
if (err == B_OK)
for (int iix = 0; iix < num_formats; iix++) {
if (formats[iix].type == fromType) {
ok = true;
break;
}
}
if (!ok)
continue;
err = use->GetOutputFormats(ids[tix], &formats, &num_formats);
if (err == B_OK)
for (int oix = 0; oix < num_formats; oix++) {
if (formats[oix].type != fromType) {
BMessage* itemmsg;
itemmsg = new BMessage(msg_translate);
itemmsg->AddInt32(translatorIdName, ids[tix]);
itemmsg->AddInt32(translatorTypeName, formats[oix].type);
intoMenu->AddItem(new BMenuItem(formats[oix].name, itemmsg));
}
}
}
delete[] ids;
return B_OK;
}
示例2: BMessage
BMessage *DragonView::_MakeDragMessage( void )
{
DragonApp *app = dynamic_cast<DragonApp *>( be_app );
BMessage *msg = new BMessage( B_SIMPLE_DATA );
// We can handle any image type that's supported by the currently
// installed Translators.
//
// A "real" application would want to add the Translators in order,
// from best to worst using the quality and capability data in the
// Translator information structure. It would also want to make sure
// that there weren't any duplicate types in the drag message.
BTranslatorRoster *translators = BTranslatorRoster::Default();
translator_id *all_translators = NULL;
int32 num_translators = 0;
status_t retval = translators->GetAllTranslators( &all_translators,
&num_translators );
if( retval == B_OK ) {
// Only add translators that support appropriate inputs/outputs.
for( int32 idx = 0; idx < num_translators; idx++ ) {
const translation_format *in_formats = NULL;
int32 num_in = 0;
// Get the list of input formats for this Translator.
retval = translators->GetInputFormats( all_translators[idx],
&in_formats,
&num_in );
if( retval != B_OK ) continue;
// Make sure it supports BBitmap inputs.
for( int32 in = 0; in < num_in; in++ ) {
if( !strcmp( in_formats[in].MIME, "image/x-be-bitmap" ) ) {
// Add this translator's output formats to the message.
const translation_format *out_formats = NULL;
int32 num_out = 0;
retval = translators->GetOutputFormats( all_translators[idx],
&out_formats,
&num_out );
if( retval != B_OK ) break;
for( int32 out = 0; out < num_out; out++ ) {
// Add every type except "image/x-be-bitmap",
// which won't be of any use to us.
if( strcmp( out_formats[out].MIME, "image/x-be-bitmap" ) ) {
msg->AddString( "be:types",
out_formats[out].MIME );
msg->AddString( "be:filetypes",
out_formats[out].MIME );
msg->AddString( "be:type_descriptions",
out_formats[out].name );
}
}
}
}
}
}
// We can also handle raw data.
msg->AddString( "be:types", B_FILE_MIME_TYPE );
msg->AddString( "be:filetypes", B_FILE_MIME_TYPE );
msg->AddString( "be:type_descriptions",
app->rsrc_strings->FindString( RSRC_Raw_Data ) );
// Add the actions that we'll support. B_LINK_TARGET doesn't make much
// sense in this context, so we'll leave it out. B_MOVE_TARGET is a
// B_COPY_TARGET followed by B_TRASH_TARGET...
msg->AddInt32( "be:actions", B_COPY_TARGET );
msg->AddInt32( "be:actions", B_TRASH_TARGET );
msg->AddInt32( "be:actions", B_MOVE_TARGET );
// A file name for dropping onto things (like the Tracker) that create
// files.
msg->AddString( "be:clip_name", "Dropped Bitmap" );
return msg;
}