本文整理汇总了C++中BMimeType::GetShortDescription方法的典型用法代码示例。如果您正苦于以下问题:C++ BMimeType::GetShortDescription方法的具体用法?C++ BMimeType::GetShortDescription怎么用?C++ BMimeType::GetShortDescription使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BMimeType
的用法示例。
在下文中一共展示了BMimeType::GetShortDescription方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: if
void
KindAttributeText::ReadValue(BString *result)
{
BMimeType mime;
char desc[B_MIME_TYPE_LENGTH];
// get the mime type
if (mime.SetType(fModel->MimeType()) != B_OK)
*result = "Unknown";
// get the short mime type description
else if (mime.GetShortDescription(desc) == B_OK)
*result = desc;
else
*result = fModel->MimeType();
fValueDirty = false;
}
示例2: if
void
KindAttributeText::ReadValue(BString* outString)
{
BMimeType mime;
char desc[B_MIME_TYPE_LENGTH];
// get the mime type
if (mime.SetType(fModel->MimeType()) != B_OK)
*outString = B_TRANSLATE("Unknown");
else if (mime.GetShortDescription(desc) == B_OK) {
// get the short mime type description
*outString = desc;
} else
*outString = fModel->MimeType();
fValueDirty = false;
}
示例3:
ShortMimeInfo::ShortMimeInfo(const BMimeType& mimeType)
:
fCommonMimeType(true)
{
fPrivateName = mimeType.Type();
char buffer[B_MIME_TYPE_LENGTH];
// weed out apps - their preferred handler is themselves
if (mimeType.GetPreferredApp(buffer) == B_OK
&& fPrivateName.ICompare(buffer) == 0) {
fCommonMimeType = false;
}
// weed out metamimes without a short description
if (mimeType.GetShortDescription(buffer) != B_OK || buffer[0] == 0)
fCommonMimeType = false;
else
fShortDescription = buffer;
}
示例4: entry
void
ImageFilePanel::SelectionChanged()
{
entry_ref ref;
Rewind();
if (GetNextSelectedRef(&ref) == B_OK) {
BEntry entry(&ref);
BNode node(&ref);
fImageView->ClearViewBitmap();
if (node.IsFile()) {
BBitmap* bitmap = BTranslationUtils::GetBitmap(&ref);
if (bitmap != NULL) {
BRect dest(fImageView->Bounds());
if (bitmap->Bounds().Width() > bitmap->Bounds().Height()) {
dest.InsetBy(0, (dest.Height() + 1
- ((bitmap->Bounds().Height() + 1)
/ (bitmap->Bounds().Width() + 1)
* (dest.Width() + 1))) / 2);
} else {
dest.InsetBy((dest.Width() + 1
- ((bitmap->Bounds().Width() + 1)
/ (bitmap->Bounds().Height() + 1)
* (dest.Height() + 1))) / 2, 0);
}
fImageView->SetViewBitmap(bitmap, bitmap->Bounds(), dest,
B_FOLLOW_LEFT | B_FOLLOW_TOP, 0);
BString resolution;
resolution << B_TRANSLATE("Resolution: ")
<< (int)(bitmap->Bounds().Width() + 1)
<< "x" << (int)(bitmap->Bounds().Height() + 1);
fResolutionView->SetText(resolution.String());
delete bitmap;
BNodeInfo nodeInfo(&node);
char type[B_MIME_TYPE_LENGTH];
if (nodeInfo.GetType(type) == B_OK) {
BMimeType mimeType(type);
mimeType.GetShortDescription(type);
// if this fails, the MIME type will be displayed
fImageTypeView->SetText(type);
} else {
BMimeType refType;
if (BMimeType::GuessMimeType(&ref, &refType) == B_OK) {
refType.GetShortDescription(type);
// if this fails, the MIME type will be displayed
fImageTypeView->SetText(type);
} else
fImageTypeView->SetText("");
}
}
} else {
fResolutionView->SetText("");
fImageTypeView->SetText("");
}
fImageView->Invalidate();
fResolutionView->Invalidate();
}
BFilePanel::SelectionChanged();
}
示例5: entry
InfoWin::InfoWin(BPoint p, FileInfo *f, BWindow* parent)
: BWindow(BRect(p, p), kEmptyStr, B_FLOATING_WINDOW_LOOK,
B_FLOATING_SUBSET_WINDOW_FEEL,
B_NOT_RESIZABLE | B_NOT_ZOOMABLE | B_NOT_MINIMIZABLE)
{
AddToSubset(parent);
typedef pair<string, string> Item;
typedef vector<Item> InfoList;
char name[B_PATH_NAME_LENGTH];
strcpy(name, f->ref.name);
strcat(name, " info");
SetTitle(name);
InfoList info;
Item item;
// Size
size_to_string(f->size, name);
if (f->count > 0) {
// This is a directory.
char str[64];
sprintf(str, kInfoInFiles, f->count);
strcat(name, str);
}
info.push_back(Item(kInfoSize, name));
// Created & modified dates
BEntry entry(&f->ref);
time_t t;
entry.GetCreationTime(&t);
strftime(name, 64, kInfoTimeFmt, localtime(&t));
info.push_back(Item(kInfoCreated, name));
entry.GetModificationTime(&t);
strftime(name, 64, kInfoTimeFmt, localtime(&t));
info.push_back(Item(kInfoModified, name));
// Kind
BMimeType* type = f->Type();
type->GetShortDescription(name);
info.push_back(Item(kInfoKind, name));
delete type;
// Path
string path;
f->GetPath(path);
info.push_back(Item(kInfoPath, path));
// Icon
BBitmap *icon = new BBitmap(BRect(0.0, 0.0, 31.0, 31.0), B_RGBA32);
entry_ref ref;
entry.GetRef(&ref);
BNodeInfo::GetTrackerIcon(&ref, icon, B_LARGE_ICON);
// Compute the window size and add the views.
BFont smallFont(be_plain_font);
smallFont.SetSize(floorf(smallFont.Size() * 0.95));
struct font_height fh;
smallFont.GetHeight(&fh);
float fontHeight = fh.ascent + fh.descent + fh.leading;
float leftWidth = 32.0;
float rightWidth = 0.0;
InfoList::iterator i = info.begin();
while (i != info.end()) {
float w = smallFont.StringWidth((*i).first.c_str()) + 2.0 * kSmallHMargin;
leftWidth = max_c(leftWidth, w);
w = smallFont.StringWidth((*i).second.c_str()) + 2.0 * kSmallHMargin;
rightWidth = max_c(rightWidth, w);
i++;
}
float winHeight = 32.0 + 4.0 * kSmallVMargin + 5.0 * (fontHeight + kSmallVMargin);
float winWidth = leftWidth + rightWidth;
ResizeTo(winWidth, winHeight);
LeftView *leftView = new LeftView(BRect(0.0, 0.0, leftWidth, winHeight), icon);
BView *rightView = new BView(
BRect(leftWidth + 1.0, 0.0, winWidth, winHeight), NULL,
B_FOLLOW_NONE, B_WILL_DRAW);
AddChild(leftView);
AddChild(rightView);
BStringView *sv = new BStringView(
BRect(kSmallHMargin, kSmallVMargin, rightView->Bounds().Width(), kSmallVMargin + 30.0),
NULL, f->ref.name, B_FOLLOW_ALL);
BFont largeFont(be_plain_font);
largeFont.SetSize(ceilf(largeFont.Size() * 1.1));
sv->SetFont(&largeFont);
rightView->AddChild(sv);
float y = 32.0 + 4.0 * kSmallVMargin;
i = info.begin();
while (i != info.end()) {
sv = new BStringView(
BRect(kSmallHMargin, y, leftView->Bounds().Width(), y + fontHeight),
//.........这里部分代码省略.........
示例6: BPopUpMenu
void
TestView::SetupTestMenu(void)
{
// These ones will always exist. Type is the default because it's probably
// going to be the one most used
BMessage *msg;
BPopUpMenu *menu = new BPopUpMenu("Test");
// Read in the types in the MIME database which have extra attributes
// associated with them
BMimeType mime;
BMessage types, info, attr;
BString string;
BMimeType::GetInstalledTypes(&types);
int32 index = 0;
while (types.FindString("types",index,&string) == B_OK)
{
index++;
mime.SetTo(string.String());
if (mime.GetAttrInfo(&info) != B_OK)
continue;
int32 infoindex = 0;
BString attrName;
BString attrPublicName;
int32 attrType;
char attrTypeName[B_MIME_TYPE_LENGTH];
mime.GetShortDescription(attrTypeName);
while (info.FindString("attr:name",infoindex,&attrName) == B_OK)
{
// This is where we create tests based on a particular type's "special" attributes
// Just string attributes are supported for now
if (info.FindInt32("attr:type",infoindex,&attrType) != B_OK ||
attrType != B_STRING_TYPE ||
info.FindString("attr:public_name",infoindex,&attrPublicName) != B_OK)
{
infoindex++;
continue;
}
BMenu *submenu = GetMenu(menu,attrTypeName);
if (!submenu)
submenu = AddMenuSorted(menu,attrTypeName);
msg = new BMessage(M_TEST_CHOSEN);
msg->AddString("name","Attribute");
msg->AddString("attrtype",attrName);
msg->AddString("attrname",attrPublicName);
msg->AddString("mimetype",string);
msg->AddString("typename",attrTypeName);
submenu->AddItem(new BMenuItem(attrPublicName.String(),msg));
infoindex++;
}
}
menu->AddItem(new BSeparatorItem(),0);
// All this weirdness is to have the "standard" tests at the top and
// the attribute tests at the bottom with a separator in between
BString testtype;
int32 i = 0;
while (fTestTypes.FindString("tests",i,&testtype) == B_OK)
i++;
i--;
while (i >= 0)
{
fTestTypes.FindString("tests",i,&testtype);
msg = new BMessage(M_TEST_CHOSEN);
msg->AddString("name",testtype);
menu->AddItem(new BMenuItem(testtype.String(),msg),0);
i--;
}
menu->Archive(&fArchivedTestMenu);
delete menu;
}
示例7: stringTitle
InfoWin::InfoWin(BPoint p, FileInfo *f, BWindow* parent)
: BWindow(BRect(p, p), kEmptyStr, B_FLOATING_WINDOW_LOOK,
B_FLOATING_SUBSET_WINDOW_FEEL,
B_NOT_RESIZABLE | B_NOT_ZOOMABLE | B_NOT_MINIMIZABLE)
{
AddToSubset(parent);
typedef pair<string, string> Item;
typedef vector<Item> InfoList;
BString stringTitle("%refName% info");
stringTitle.ReplaceFirst("%refName%", f->ref.name);
SetTitle(stringTitle.String());
InfoList info;
Item item;
// Size
BString name;
if (f->count > 0) {
// This is a directory, include file count information
static BMessageFormat format(B_TRANSLATE(
"%size% in {0, plural, one{# file} other{# files}}"));
format.Format(name, f->count);
} else
name = "%size%";
char tmp[B_PATH_NAME_LENGTH] = { 0 };
string_for_size(f->size, tmp, sizeof(tmp));
name.ReplaceFirst("%size%", tmp);
info.push_back(Item(B_TRANSLATE_MARK("Size"), name.String()));
// Created & modified dates
BEntry entry(&f->ref);
time_t t;
entry.GetCreationTime(&t);
strftime(tmp, 64, B_TRANSLATE("%a, %d %b %Y, %r"), localtime(&t));
info.push_back(Item(B_TRANSLATE("Created"), tmp));
entry.GetModificationTime(&t);
strftime(tmp, 64, B_TRANSLATE("%a, %d %b %Y, %r"), localtime(&t));
info.push_back(Item(B_TRANSLATE("Modified"), tmp));
// Kind
BMimeType* type = f->Type();
type->GetShortDescription(tmp);
info.push_back(Item(B_TRANSLATE("Kind"), tmp));
delete type;
// Path
string path;
f->GetPath(path);
info.push_back(Item(B_TRANSLATE("Path"), path));
// Icon
BBitmap *icon = new BBitmap(BRect(0.0, 0.0, 31.0, 31.0), B_RGBA32);
entry_ref ref;
entry.GetRef(&ref);
BNodeInfo::GetTrackerIcon(&ref, icon, B_LARGE_ICON);
// Compute the window size and add the views.
BFont smallFont(be_plain_font);
smallFont.SetSize(floorf(smallFont.Size() * 0.95));
struct font_height fh;
smallFont.GetHeight(&fh);
float fontHeight = fh.ascent + fh.descent + fh.leading;
float leftWidth = 32.0;
float rightWidth = 0.0;
InfoList::iterator i = info.begin();
while (i != info.end()) {
float w = smallFont.StringWidth((*i).first.c_str())
+ 2.0 * kSmallHMargin;
leftWidth = max_c(leftWidth, w);
w = smallFont.StringWidth((*i).second.c_str()) + 2.0 * kSmallHMargin;
rightWidth = max_c(rightWidth, w);
i++;
}
float winHeight = 32.0 + 4.0 * kSmallVMargin + 5.0 * (fontHeight
+ kSmallVMargin);
float winWidth = leftWidth + rightWidth;
ResizeTo(winWidth, winHeight);
LeftView *leftView = new LeftView(BRect(0.0, 0.0, leftWidth, winHeight),
icon);
BView *rightView = new BView(
BRect(leftWidth + 1.0, 0.0, winWidth, winHeight), NULL,
B_FOLLOW_NONE, B_WILL_DRAW);
AddChild(leftView);
AddChild(rightView);
BStringView *sv = new BStringView(
BRect(kSmallHMargin, kSmallVMargin, rightView->Bounds().Width(),
kSmallVMargin + 30.0), NULL, f->ref.name, B_FOLLOW_ALL);
BFont largeFont(be_plain_font);
//.........这里部分代码省略.........