本文整理汇总了C++中B_TRANSLATE函数的典型用法代码示例。如果您正苦于以下问题:C++ B_TRANSLATE函数的具体用法?C++ B_TRANSLATE怎么用?C++ B_TRANSLATE使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了B_TRANSLATE函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: BPopUpMenu
void
PadView::DisplayMenu(BPoint where, LaunchButton* button) const
{
MainWindow* window = dynamic_cast<MainWindow*>(Window());
if (window == NULL)
return;
LaunchButton* nearestButton = button;
if (!nearestButton) {
// find the nearest button
for (int32 i = 0; (nearestButton = ButtonAt(i)); i++) {
if (nearestButton->Frame().top > where.y)
break;
}
}
BPopUpMenu* menu = new BPopUpMenu(B_TRANSLATE("launch popup"), false, false);
// add button
BMessage* message = new BMessage(MSG_ADD_SLOT);
message->AddPointer("be:source", (void*)nearestButton);
BMenuItem* item = new BMenuItem(B_TRANSLATE("Add button here"), message);
item->SetTarget(window);
menu->AddItem(item);
// button options
if (button) {
// clear button
message = new BMessage(MSG_CLEAR_SLOT);
message->AddPointer("be:source", (void*)button);
item = new BMenuItem(B_TRANSLATE("Clear button"), message);
item->SetTarget(window);
menu->AddItem(item);
// remove button
message = new BMessage(MSG_REMOVE_SLOT);
message->AddPointer("be:source", (void*)button);
item = new BMenuItem(B_TRANSLATE("Remove button"), message);
item->SetTarget(window);
menu->AddItem(item);
// set button description
if (button->Ref()) {
message = new BMessage(MSG_SET_DESCRIPTION);
message->AddPointer("be:source", (void*)button);
item = new BMenuItem(B_TRANSLATE("Set description"B_UTF8_ELLIPSIS),
message);
item->SetTarget(window);
menu->AddItem(item);
}
}
menu->AddSeparatorItem();
// window settings
BMenu* settingsM = new BMenu(B_TRANSLATE("Settings"));
settingsM->SetFont(be_plain_font);
const char* toggleLayoutLabel;
if (fButtonLayout->Orientation() == B_HORIZONTAL)
toggleLayoutLabel = B_TRANSLATE("Vertical layout");
else
toggleLayoutLabel = B_TRANSLATE("Horizontal layout");
item = new BMenuItem(toggleLayoutLabel, new BMessage(MSG_TOGGLE_LAYOUT));
item->SetTarget(this);
settingsM->AddItem(item);
BMenu* iconSizeM = new BMenu(B_TRANSLATE("Icon size"));
for (uint32 i = 0; i < sizeof(kIconSizes) / sizeof(uint32); i++) {
uint32 iconSize = kIconSizes[i];
message = new BMessage(MSG_SET_ICON_SIZE);
message->AddInt32("size", iconSize);
BString label;
label << iconSize << " x " << iconSize;
item = new BMenuItem(label.String(), message);
item->SetTarget(this);
item->SetMarked(IconSize() == iconSize);
iconSizeM->AddItem(item);
}
settingsM->AddItem(iconSizeM);
item = new BMenuItem(B_TRANSLATE("Ignore double-click"),
new BMessage(MSG_SET_IGNORE_DOUBLECLICK));
item->SetTarget(this);
item->SetMarked(IgnoreDoubleClick());
settingsM->AddItem(item);
uint32 what = window->Look() == B_BORDERED_WINDOW_LOOK ? MSG_SHOW_BORDER : MSG_HIDE_BORDER;
item = new BMenuItem(B_TRANSLATE("Show window border"), new BMessage(what));
item->SetTarget(window);
item->SetMarked(what == MSG_HIDE_BORDER);
settingsM->AddItem(item);
item = new BMenuItem(B_TRANSLATE("Auto-raise"), new BMessage(MSG_TOGGLE_AUTORAISE));
item->SetTarget(window);
item->SetMarked(window->AutoRaise());
settingsM->AddItem(item);
item = new BMenuItem(B_TRANSLATE("Show on all workspaces"), new BMessage(MSG_SHOW_ON_ALL_WORKSPACES));
item->SetTarget(window);
item->SetMarked(window->ShowOnAllWorkspaces());
settingsM->AddItem(item);
menu->AddItem(settingsM);
menu->AddSeparatorItem();
//.........这里部分代码省略.........
示例2: BWindow
ApplicationTypeWindow::ApplicationTypeWindow(BPoint position,
const BEntry& entry)
:
BWindow(BRect(0.0f, 0.0f, 250.0f, 340.0f).OffsetBySelf(position),
B_TRANSLATE("Application type"), B_TITLED_WINDOW,
B_NOT_ZOOMABLE | B_ASYNCHRONOUS_CONTROLS |
B_FRAME_EVENTS | B_AUTO_UPDATE_SIZE_LIMITS),
fChangedProperties(0)
{
float padding = be_control_look->DefaultItemSpacing();
BAlignment labelAlignment = be_control_look->DefaultLabelAlignment();
BMenuBar* menuBar = new BMenuBar((char*)NULL);
menuBar->SetExplicitAlignment(BAlignment(B_ALIGN_LEFT, B_ALIGN_TOP));
BMenu* menu = new BMenu(B_TRANSLATE("File"));
fSaveMenuItem = new BMenuItem(B_TRANSLATE("Save"),
new BMessage(kMsgSave), 'S');
fSaveMenuItem->SetEnabled(false);
menu->AddItem(fSaveMenuItem);
BMenuItem* item;
menu->AddItem(item = new BMenuItem(
B_TRANSLATE("Save into resource file" B_UTF8_ELLIPSIS), NULL));
item->SetEnabled(false);
menu->AddSeparatorItem();
menu->AddItem(new BMenuItem(B_TRANSLATE("Close"),
new BMessage(B_QUIT_REQUESTED), 'W', B_COMMAND_KEY));
menuBar->AddItem(menu);
// Signature
fSignatureControl = new BTextControl(B_TRANSLATE("Signature:"), NULL,
new BMessage(kMsgSignatureChanged));
fSignatureControl->SetModificationMessage(
new BMessage(kMsgSignatureChanged));
// filter out invalid characters that can't be part of a MIME type name
BTextView* textView = fSignatureControl->TextView();
textView->SetMaxBytes(B_MIME_TYPE_LENGTH);
const char* disallowedCharacters = "<>@,;:\"()[]?= ";
for (int32 i = 0; disallowedCharacters[i]; i++) {
textView->DisallowChar(disallowedCharacters[i]);
}
// "Application Flags" group
BBox* flagsBox = new BBox("flagsBox");
fFlagsCheckBox = new BCheckBox("flags", B_TRANSLATE("Application flags"),
new BMessage(kMsgToggleAppFlags));
fFlagsCheckBox->SetValue(B_CONTROL_ON);
fSingleLaunchButton = new BRadioButton("single",
B_TRANSLATE("Single launch"), new BMessage(kMsgAppFlagsChanged));
fMultipleLaunchButton = new BRadioButton("multiple",
B_TRANSLATE("Multiple launch"), new BMessage(kMsgAppFlagsChanged));
fExclusiveLaunchButton = new BRadioButton("exclusive",
B_TRANSLATE("Exclusive launch"), new BMessage(kMsgAppFlagsChanged));
fArgsOnlyCheckBox = new BCheckBox("args only", B_TRANSLATE("Args only"),
new BMessage(kMsgAppFlagsChanged));
fBackgroundAppCheckBox = new BCheckBox("background",
B_TRANSLATE("Background app"), new BMessage(kMsgAppFlagsChanged));
BLayoutBuilder::Grid<>(flagsBox, 0, 0)
.SetInsets(padding, padding * 2, padding, padding)
.Add(fSingleLaunchButton, 0, 0).Add(fArgsOnlyCheckBox, 1, 0)
.Add(fMultipleLaunchButton, 0, 1).Add(fBackgroundAppCheckBox, 1, 1)
.Add(fExclusiveLaunchButton, 0, 2);
flagsBox->SetLabel(fFlagsCheckBox);
// "Icon" group
BBox* iconBox = new BBox("IconBox");
iconBox->SetLabel(B_TRANSLATE("Icon"));
fIconView = new IconView("icon");
fIconView->SetModificationMessage(new BMessage(kMsgIconChanged));
BLayoutBuilder::Group<>(iconBox, B_HORIZONTAL)
.SetInsets(padding, padding * 2, padding, padding)
.Add(fIconView);
// "Supported Types" group
BBox* typeBox = new BBox("typesBox");
typeBox->SetLabel(B_TRANSLATE("Supported types"));
fTypeListView = new SupportedTypeListView("Suppported Types",
B_SINGLE_SELECTION_LIST);
fTypeListView->SetSelectionMessage(new BMessage(kMsgTypeSelected));
BScrollView* scrollView = new BScrollView("type scrollview", fTypeListView,
B_FRAME_EVENTS | B_WILL_DRAW, false, true);
fAddTypeButton = new BButton("add type",
B_TRANSLATE("Add" B_UTF8_ELLIPSIS), new BMessage(kMsgAddType));
//.........这里部分代码省略.........
示例3: switch
void
MediaWindow::MessageReceived(BMessage* message)
{
switch(message->what)
{
case ML_INIT_MEDIA:
InitMedia(false);
break;
case ML_RESTART_MEDIA_SERVER:
{
thread_id thread = spawn_thread(&MediaWindow::RestartMediaServices,
"restart_thread", B_NORMAL_PRIORITY, this);
if (thread < B_OK)
fprintf(stderr, "couldn't create restart thread\n");
else
resume_thread(thread);
break;
}
case B_MEDIA_WEB_CHANGED:
case ML_SELECTED_NODE:
{
PRINT_OBJECT(*message);
MediaListItem* item = static_cast<MediaListItem*>(
fListView->ItemAt(fListView->CurrentSelection()));
if (!item)
break;
fCurrentNode.SetTo(NULL);
_ClearParamView();
item->AlterWindow(this);
break;
}
case B_SOME_APP_LAUNCHED:
{
PRINT_OBJECT(*message);
if (!fAlert)
break;
BString mimeSig;
if (message->FindString("be:signature", &mimeSig) == B_OK
&& (mimeSig == "application/x-vnd.Be.addon-host"
|| mimeSig == "application/x-vnd.Be.media-server")) {
fAlert->Lock();
fAlert->TextView()->SetText(
B_TRANSLATE("Starting media server" B_UTF8_ELLIPSIS));
fAlert->Unlock();
}
}
break;
case B_SOME_APP_QUIT:
{
PRINT_OBJECT(*message);
BString mimeSig;
if (message->FindString("be:signature", &mimeSig) == B_OK) {
if (mimeSig == "application/x-vnd.Be.addon-host"
|| mimeSig == "application/x-vnd.Be.media-server") {
BMediaRoster* roster = BMediaRoster::CurrentRoster();
if (roster && roster->Lock())
roster->Quit();
}
}
}
break;
default:
BWindow::MessageReceived(message);
break;
}
}
示例4: switch
// Handling of user interface and other events
void MainWindow::MessageReceived(BMessage *message)
{
switch(message->what){
case SELECTION_CHANGED:
BRow *row;
row = teamView->RowAt(message->FindInt32("index"));
if(row != NULL && message->FindInt32("buttons") == B_SECONDARY_MOUSE_BUTTON){
BPoint point;
uint32 state;
teamView->GetMouse(&point,&state);
BPoint p2 = teamView->ConvertToScreen(point);
p2.x -= 5.0;
p2.y -= 5.0;
//if(fItemMenu->FindMarked())
// fItemMenu->FindMarked()->SetMarked(false);
teamView->SelectionMessage()->ReplaceInt32("buttons",0);
teamView->ActionMenu()->Go(p2, true, true, true);
//fItemMenu->Go(p2, true, true, true);
}
SetButtonState();
break;
case IE_MAINWINDOW_MAINMENU_ACTION_KILL:
case IE_MAINWINDOW_MAINKILL:
DoKill();
UpdateTeams();
SetButtonState();
break;
case IE_MAINWINDOW_MAINMENU_ACTION_SUSPEND:
case IE_MAINWINDOW_MAINSUSPEND:
DoSuspend();
UpdateTeams();
SetButtonState();
break;
case IE_MAINWINDOW_MAINMENU_ACTION_RESUME:
case IE_MAINWINDOW_MAINRESUME:
DoResume();
UpdateTeams();
SetButtonState();
break;
case SET_PRIORITY: {
int32 priority = message->FindInt32("priority");
DoPriority(priority);
UpdateTeams();
SetButtonState();
break;
}
case IE_MAINWINDOW_MAINPRIORITYVALUE:
// takes priority from text field
DoPriority();
UpdateTeams();
SetButtonState();
break;
case IE_MAINWINDOW_MAINUPDATE:
UpdateTeams();
SetButtonState();
break;
case B_ABOUT_REQUESTED: // "About…" is selected from menu…
{
BAboutWindow* fAboutWin = new BAboutWindow(B_TRANSLATE_SYSTEM_NAME("Slayer"), slayer_signature);
fAboutWin->AddDescription(B_TRANSLATE("A thread manager for Haiku"));
fAboutWin->SetVersion(SLAYER_VERSION);
fAboutWin->AddCopyright(1999, "Arto Jalkanen");
const char* authors[] = {
"Arto Jalkanen ([email protected])",
NULL
};
fAboutWin->AddAuthors(authors);
fAboutWin->Show();
}
break;
case IE_MAINWINDOW_MAINMENU_FILE_DOCS__:
{
BMessage message(B_REFS_RECEIVED);
message.AddString("url", ProjectWebsite);
be_roster->Launch("text/html", &message);
}
break;
case IE_MAINWINDOW_MAINMENU_FILE_QUIT: // "Quit" is selected from menu…
be_app->PostMessage(B_QUIT_REQUESTED);
break;
case IE_MAINWINDOW_MAINMENU_WINDOWS_SETTINGS:
{
const char* windowSettingsTitle = B_TRANSLATE("Settings");
BWindow *settings = slayer->FindWindow(windowSettingsTitle);
if (!settings)
new SettingsWindow(windowSettingsTitle);
else if (settings->Lock()) {
settings->Activate(true);
settings->Unlock();
}
}
break;
default:
BWindow::MessageReceived(message);
break;
}
//.........这里部分代码省略.........
示例5: SetLayout
void
TouchpadPrefView::SetupView()
{
SetLayout(new BGroupLayout(B_VERTICAL));
BBox* scrollBox = new BBox("Touchpad");
scrollBox->SetLabel(B_TRANSLATE("Scrolling"));
fTouchpadView = new TouchpadView(BRect(0, 0, 130, 120));
fTouchpadView->SetExplicitMaxSize(BSize(130, 120));
// Create the "Mouse Speed" slider...
fScrollAccelSlider = new BSlider("scroll_accel",
B_TRANSLATE("Scroll acceleration"),
new BMessage(SCROLL_CONTROL_CHANGED), 0, 20, B_HORIZONTAL);
fScrollAccelSlider->SetHashMarks(B_HASH_MARKS_BOTTOM);
fScrollAccelSlider->SetHashMarkCount(7);
fScrollAccelSlider->SetLimitLabels(B_TRANSLATE("Slow"),
B_TRANSLATE("Fast"));
fScrollStepXSlider = new BSlider("scroll_stepX",
B_TRANSLATE("Horizontal scroll speed"),
new BMessage(SCROLL_CONTROL_CHANGED),
0, 20, B_HORIZONTAL);
fScrollStepXSlider->SetHashMarks(B_HASH_MARKS_BOTTOM);
fScrollStepXSlider->SetHashMarkCount(7);
fScrollStepXSlider->SetLimitLabels(B_TRANSLATE("Slow"),
B_TRANSLATE("Fast"));
fScrollStepYSlider = new BSlider("scroll_stepY",
B_TRANSLATE("Vertical scroll speed"),
new BMessage(SCROLL_CONTROL_CHANGED), 0, 20, B_HORIZONTAL);
fScrollStepYSlider->SetHashMarks(B_HASH_MARKS_BOTTOM);
fScrollStepYSlider->SetHashMarkCount(7);
fScrollStepYSlider->SetLimitLabels(B_TRANSLATE("Slow"),
B_TRANSLATE("Fast"));
fTwoFingerBox = new BCheckBox(B_TRANSLATE("Two finger scrolling"),
new BMessage(SCROLL_CONTROL_CHANGED));
fTwoFingerHorizontalBox = new BCheckBox(
B_TRANSLATE("Horizontal scrolling"),
new BMessage(SCROLL_CONTROL_CHANGED));
BGroupView* scrollPrefLeftLayout = new BGroupView(B_VERTICAL);
BLayoutBuilder::Group<>(scrollPrefLeftLayout)
.Add(fTouchpadView)
.Add(fTwoFingerBox)
.AddGroup(B_HORIZONTAL)
.AddStrut(20)
.Add(fTwoFingerHorizontalBox);
BGroupView* scrollPrefRightLayout = new BGroupView(B_VERTICAL);
scrollPrefRightLayout->AddChild(fScrollAccelSlider);
scrollPrefRightLayout->AddChild(fScrollStepXSlider);
scrollPrefRightLayout->AddChild(fScrollStepYSlider);
BGroupLayout* scrollPrefLayout = new BGroupLayout(B_HORIZONTAL);
scrollPrefLayout->SetSpacing(10);
scrollPrefLayout->SetInsets(10, scrollBox->TopBorderOffset() * 2 + 10, 10,
10);
scrollBox->SetLayout(scrollPrefLayout);
scrollPrefLayout->AddView(scrollPrefLeftLayout);
scrollPrefLayout->AddItem(BSpaceLayoutItem::CreateVerticalStrut(15));
scrollPrefLayout->AddView(scrollPrefRightLayout);
BBox* tapBox = new BBox("tapbox");
tapBox->SetLabel(B_TRANSLATE("Tap gesture"));
BGroupLayout* tapPrefLayout = new BGroupLayout(B_HORIZONTAL);
tapPrefLayout->SetInsets(10, tapBox->TopBorderOffset() * 2 + 10, 10, 10);
tapBox->SetLayout(tapPrefLayout);
fTapSlider = new BSlider("tap_sens", B_TRANSLATE("Tap click sensitivity"),
new BMessage(TAP_CONTROL_CHANGED), 0, 20, B_HORIZONTAL);
fTapSlider->SetHashMarks(B_HASH_MARKS_BOTTOM);
fTapSlider->SetHashMarkCount(7);
fTapSlider->SetLimitLabels(B_TRANSLATE("Off"), B_TRANSLATE("High"));
tapPrefLayout->AddView(fTapSlider);
BGroupView* buttonView = new BGroupView(B_HORIZONTAL);
fDefaultButton = new BButton(B_TRANSLATE("Defaults"),
new BMessage(DEFAULT_SETTINGS));
buttonView->AddChild(fDefaultButton);
buttonView->GetLayout()->AddItem(
BSpaceLayoutItem::CreateHorizontalStrut(7));
fRevertButton = new BButton(B_TRANSLATE("Revert"),
new BMessage(REVERT_SETTINGS));
fRevertButton->SetEnabled(false);
buttonView->AddChild(fRevertButton);
buttonView->GetLayout()->AddItem(BSpaceLayoutItem::CreateGlue());
BGroupLayout* layout = new BGroupLayout(B_VERTICAL);
layout->SetInsets(10, 10, 10, 10);
layout->SetSpacing(10);
BView* rootView = new BView("root view", 0, layout);
AddChild(rootView);
rootView->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
//.........这里部分代码省略.........
示例6: switch
void
AttributeWindow::MessageReceived(BMessage* message)
{
switch (message->what) {
case kMsgAttributeUpdated:
case kMsgAlignmentChosen:
case kMsgTypeChosen:
_CheckDisplayAs();
_CheckAcceptable();
break;
case kMsgDisplayAsChosen:
fSpecialControl->SetEnabled(!_DefaultDisplayAs()->IsMarked());
_CheckAcceptable();
break;
case kMsgVisibilityChanged:
{
bool enabled = fVisibleCheckBox->Value() != B_CONTROL_OFF;
fDisplayAsMenuField->SetEnabled(enabled);
fWidthControl->SetEnabled(enabled);
fAlignmentMenuField->SetEnabled(enabled);
fEditableCheckBox->SetEnabled(enabled);
_CheckDisplayAs();
_CheckAcceptable();
break;
}
case kMsgAccept:
{
BMessage attributes;
status_t status = fMimeType.GetAttrInfo(&attributes);
if (status == B_OK) {
// replace the entry, and remove any equivalent entries
BList list;
const char* newAttribute = fAttributeControl->Text();
const char* attribute;
for (int32 i = 0; attributes.FindString("attr:name", i,
&attribute) == B_OK; i++) {
if (!strcmp(fAttribute.Name(), attribute)
|| !strcmp(newAttribute, attribute)) {
// remove this item
continue;
}
AttributeItem* item = create_attribute_item(attributes, i);
if (item != NULL)
list.AddItem(item);
}
list.AddItem(_NewItemFromCurrent());
// Copy them to a new message (their memory is still part of the
// original BMessage)
BMessage newAttributes;
for (int32 i = 0; i < list.CountItems(); i++) {
AttributeItem* item = (AttributeItem*)list.ItemAt(i);
newAttributes.AddString("attr:name", item->Name());
newAttributes.AddString("attr:public_name", item->PublicName());
newAttributes.AddInt32("attr:type", (int32)item->Type());
newAttributes.AddString("attr:display_as", item->DisplayAs());
newAttributes.AddInt32("attr:alignment", item->Alignment());
newAttributes.AddInt32("attr:width", item->Width());
newAttributes.AddBool("attr:viewable", item->Visible());
newAttributes.AddBool("attr:editable", item->Editable());
delete item;
}
status = fMimeType.SetAttrInfo(&newAttributes);
}
if (status != B_OK) {
error_alert(B_TRANSLATE("Could not change attributes"),
status);
}
PostMessage(B_QUIT_REQUESTED);
break;
}
default:
BWindow::MessageReceived(message);
break;
}
}
示例7: if
status_t
RTFTranslator::Identify(BPositionIO *stream,
const translation_format *format, BMessage *ioExtension,
translator_info *info, uint32 outType)
{
if (!outType)
outType = B_TRANSLATOR_TEXT;
else if (outType != B_TRANSLATOR_TEXT && outType != B_STYLED_TEXT_FORMAT
&& outType != RTF_TEXT_FORMAT)
return B_NO_TRANSLATOR;
RTF::Parser parser(*stream);
status_t status = parser.Identify();
if (status == B_OK) {
// Source data is RTF. We can translate to RTF (no-op), plaintext, or
// styled text.
// return information about the data in the stream
info->type = B_TRANSLATOR_TEXT; //RTF_TEXT_FORMAT;
info->group = B_TRANSLATOR_TEXT;
info->quality = RTF_IN_QUALITY;
info->capability = RTF_IN_CAPABILITY;
strlcpy(info->name, B_TRANSLATE("RichTextFormat file"),
sizeof(info->name));
strcpy(info->MIME, "text/rtf");
} else {
// Not an RTF file. We can only work with it if we are translating to
// RTF.
if (outType != RTF_TEXT_FORMAT)
return B_NO_TRANSLATOR;
stream->Seek(0, SEEK_SET);
TranslatorStyledTextStreamHeader header;
stream->Read(&header, sizeof(header));
swap_data(B_UINT32_TYPE, &header, sizeof(header),
B_SWAP_BENDIAN_TO_HOST);
stream->Seek(0, SEEK_SET);
if (header.header.magic == B_STYLED_TEXT_FORMAT
&& header.header.header_size == (int32)sizeof(header)
&& header.header.data_size == 0
&& header.version == 100) {
info->type = B_STYLED_TEXT_FORMAT;
info->group = B_TRANSLATOR_TEXT;
info->quality = STXT_IN_QUALITY;
info->capability = STXT_IN_CAPABILITY;
strlcpy(info->name, B_TRANSLATE("Be style text file"),
sizeof(info->name));
strcpy(info->MIME, "text/x-vnd.Be-stxt");
} else {
info->type = B_TRANSLATOR_TEXT;
info->group = B_TRANSLATOR_TEXT;
info->quality = TEXT_IN_QUALITY;
info->capability = TEXT_IN_CAPABILITY;
strlcpy(info->name, B_TRANSLATE("Plain text file"),
sizeof(info->name));
strcpy(info->MIME, "text/plain");
}
}
return B_OK;
}
示例8: BBox
AutomountSettingsPanel::AutomountSettingsPanel(BMessage* settings,
const BMessenger& target)
:
BBox("", B_WILL_DRAW | B_FRAME_EVENTS | B_NAVIGABLE_JUMP, B_NO_BORDER),
fTarget(target)
{
const float spacing = be_control_look->DefaultItemSpacing();
// "Automatic Disk Mounting" group
BBox* autoMountBox = new BBox("autoMountBox", B_WILL_DRAW | B_FRAME_EVENTS
| B_PULSE_NEEDED | B_NAVIGABLE_JUMP);
autoMountBox->SetLabel(B_TRANSLATE("Automatic disk mounting"));
BGroupLayout* autoMountLayout = new BGroupLayout(B_VERTICAL, 0);
autoMountBox->SetLayout(autoMountLayout);
autoMountLayout->SetInsets(spacing,
autoMountBox->InnerFrame().top + spacing / 2, spacing, spacing);
fScanningDisabledCheck = new BRadioButton("scanningOff",
B_TRANSLATE("Don't automount"),
new BMessage(kAutomountSettingsChanged));
fAutoMountAllBFSCheck = new BRadioButton("autoBFS",
B_TRANSLATE("All BeOS disks"), new BMessage(kAutomountSettingsChanged));
fAutoMountAllCheck = new BRadioButton("autoAll",
B_TRANSLATE("All disks"), new BMessage(kAutomountSettingsChanged));
// "Disk Mounting During Boot" group
BBox* bootMountBox = new BBox("", B_WILL_DRAW | B_FRAME_EVENTS
| B_PULSE_NEEDED | B_NAVIGABLE_JUMP);
bootMountBox->SetLabel(B_TRANSLATE("Disk mounting during boot"));
BGroupLayout* bootMountLayout = new BGroupLayout(B_VERTICAL, 0);
bootMountBox->SetLayout(bootMountLayout);
bootMountLayout->SetInsets(spacing,
bootMountBox->InnerFrame().top + spacing / 2, spacing, spacing);
fInitialDontMountCheck = new BRadioButton("initialNone",
B_TRANSLATE("Only the boot disk"),
new BMessage(kBootMountSettingsChanged));
fInitialMountRestoreCheck = new BRadioButton("initialRestore",
B_TRANSLATE("Previously mounted disks"),
new BMessage(kBootMountSettingsChanged));
fInitialMountAllBFSCheck = new BRadioButton("initialBFS",
B_TRANSLATE("All BeOS disks"),
new BMessage(kBootMountSettingsChanged));
fInitialMountAllCheck = new BRadioButton("initialAll",
B_TRANSLATE("All disks"), new BMessage(kBootMountSettingsChanged));
fEjectWhenUnmountingCheckBox = new BCheckBox("ejectWhenUnmounting",
B_TRANSLATE("Eject when unmounting"),
new BMessage(kEjectWhenUnmountingChanged));
// Buttons
fDone = new BButton(B_TRANSLATE("Done"), new BMessage(B_QUIT_REQUESTED));
fMountAllNow = new BButton("mountAll", B_TRANSLATE("Mount all disks now"),
new BMessage(kMountAllNow));
fDone->MakeDefault(true);
// Layout the controls
BGroupView* contentView = new BGroupView(B_VERTICAL, 0);
AddChild(contentView);
BLayoutBuilder::Group<>(contentView)
.AddGroup(B_VERTICAL, spacing)
.SetInsets(spacing, spacing, spacing, spacing)
.AddGroup(autoMountLayout)
.Add(fScanningDisabledCheck)
.Add(fAutoMountAllBFSCheck)
.Add(fAutoMountAllCheck)
.End()
.AddGroup(bootMountLayout)
.Add(fInitialDontMountCheck)
.Add(fInitialMountRestoreCheck)
.Add(fInitialMountAllBFSCheck)
.Add(fInitialMountAllCheck)
.End()
.AddGroup(B_HORIZONTAL)
.AddStrut(spacing - 1)
.Add(fEjectWhenUnmountingCheckBox)
.End()
.End()
.Add(new BSeparatorView(B_HORIZONTAL/*, B_FANCY_BORDER*/))
.AddGroup(B_HORIZONTAL, spacing)
.SetInsets(0, spacing, spacing, spacing)
.AddGlue()
.Add(fMountAllNow)
.Add(fDone);
// Apply the settings
bool result;
if (settings->FindBool("autoMountAll", &result) == B_OK && result)
fAutoMountAllCheck->SetValue(B_CONTROL_ON);
//.........这里部分代码省略.........
示例9: B_TRANSLATE
const char *
RTFTranslator::TranslatorName() const
{
return B_TRANSLATE("RTF text files");
}
示例10: switch
void
HWindow::MessageReceived(BMessage* message)
{
switch (message->what) {
case M_OTHER_MESSAGE:
{
BMenuField* menufield
= dynamic_cast<BMenuField*>(FindView("filemenu"));
if (menufield == NULL)
return;
BMenu* menu = menufield->Menu();
HEventRow* row = (HEventRow*)fEventList->CurrentSelection();
if (row != NULL) {
BPath path(row->Path());
if (path.InitCheck() != B_OK) {
BMenuItem* item = menu->FindItem(B_TRANSLATE("<none>"));
if (item != NULL)
item->SetMarked(true);
} else {
BMenuItem* item = menu->FindItem(path.Leaf());
if (item != NULL)
item->SetMarked(true);
}
}
fFilePanel->Show();
break;
}
case B_SIMPLE_DATA:
case B_REFS_RECEIVED:
{
entry_ref ref;
HEventRow* row = (HEventRow*)fEventList->CurrentSelection();
if (message->FindRef("refs", &ref) == B_OK && row != NULL) {
BMenuField* menufield
= dynamic_cast<BMenuField*>(FindView("filemenu"));
if (menufield == NULL)
return;
BMenu* menu = menufield->Menu();
// check audio file
BNode node(&ref);
BNodeInfo ninfo(&node);
char type[B_MIME_TYPE_LENGTH + 1];
ninfo.GetType(type);
BMimeType mtype(type);
BMimeType superType;
mtype.GetSupertype(&superType);
if (superType.Type() == NULL
|| strcmp(superType.Type(), "audio") != 0) {
beep();
BAlert* alert = new BAlert("",
B_TRANSLATE("This is not an audio file."),
B_TRANSLATE("OK"), NULL, NULL,
B_WIDTH_AS_USUAL, B_STOP_ALERT);
alert->SetFlags(alert->Flags() | B_CLOSE_ON_ESCAPE);
alert->Go();
break;
}
// add file item
BMessage* msg = new BMessage(M_ITEM_MESSAGE);
BPath path(&ref);
msg->AddRef("refs", &ref);
BMenuItem* menuitem = menu->FindItem(path.Leaf());
if (menuitem == NULL)
menu->AddItem(menuitem = new BMenuItem(path.Leaf(), msg), 0);
// refresh item
fEventList->SetPath(BPath(&ref).Path());
// check file menu
if (menuitem != NULL)
menuitem->SetMarked(true);
}
break;
}
case M_PLAY_MESSAGE:
{
HEventRow* row = (HEventRow*)fEventList->CurrentSelection();
if (row != NULL) {
const char* path = row->Path();
if (path != NULL) {
entry_ref ref;
::get_ref_for_path(path, &ref);
delete fPlayer;
fPlayer = new BFileGameSound(&ref, false);
fPlayer->StartPlaying();
}
}
break;
}
case M_STOP_MESSAGE:
{
if (fPlayer == NULL)
break;
if (fPlayer->IsPlaying()) {
fPlayer->StopPlaying();
delete fPlayer;
//.........这里部分代码省略.........
示例11: SetLowColor
void SnowView::Draw(BRect ur)
{
int i;
if (!fCachedParent) {
if (!fShowClickMe) { /* show "drag me" */
SetLowColor(ViewColor());
SetHighColor(0,0,0);
SetFontSize(12);
DrawString(B_TRANSLATE("Drag me on your desktop"B_UTF8_ELLIPSIS),
BPoint(15,25));
BPoint arrowHead(Bounds().RightBottom() + BPoint(-10,-10));
StrokeLine(arrowHead, arrowHead - BPoint(7,0));
StrokeLine(arrowHead, arrowHead - BPoint(0,7));
StrokeLine(arrowHead, arrowHead - BPoint(12,12));
return;
} else {
SetLowColor(ViewColor());
SetHighColor(0,0,0);
SetFontSize(12);
DrawString(B_TRANSLATE("Click me to remove BSnow"B_UTF8_ELLIPSIS),
BPoint(15,25));
return;
}
}
//printf("Draw()\n");
uint32 cw = fCurrentWorkspace;
if (fFlakes[cw] == NULL)
return;
/* draw the snow already fallen */
// BRect fallenRect(Bounds());
// fallenRect.top = fallenRect.bottom - FALLEN_HEIGHT;
// if (ur.Intersects(fallenRect)) {
//if (fFallenBmp->Lock()) {
// DrawBitmap(fFallenBmp, fallenRect);
// fFallenBmp->Unlock();
//}
int32 cnt = fFallenReg->CountRects();
// drawing_mode oldmode = DrawingMode();
// SetDrawingMode(B_OP_ADD);
for (i=0; i<cnt; i++) {
BRect r = fFallenReg->RectAt(i);
// SetHighColor(245, 245, 245, 200);
// FillRect(r);
// SetHighColor(255, 255, 255, 255);
// r.InsetBy(1,1);
FillRect(r);
}
// SetDrawingMode(oldmode);
// }
/* draw our flakes */
for (i=0; i<fNumFlakes; i++) {
int pat;
if (!ur.Contains(BRect(fFlakes[cw][i].pos-BPoint(4,4), fFlakes[cw][i].pos+BPoint(4,4))))
continue;
if (fFlakes[cw][i].weight == 0)
continue;
pat = (fFlakes[cw][i].weight>3)?1:0;
//FillRect(BRect(fFlakes[cw][i].pos-BPoint(PAT_HOTSPOT),fFlakes[cw][i].pos-BPoint(PAT_HOTSPOT)+BPoint(7,7)), gFlakePatterns[pat]);
/*
StrokeLine(fFlakes[cw][i].pos+BPoint(-1,-1),
fFlakes[cw][i].pos+BPoint(1,1));
StrokeLine(fFlakes[cw][i].pos+BPoint(-1,1),
fFlakes[cw][i].pos+BPoint(1,-1));
*/
DrawBitmap(fFlakeBitmaps[pat], fFlakes[cw][i].pos-BPoint(PAT_HOTSPOT));
}
}
示例12: find_directory
void
DataTranslationsApplication::RefsReceived(BMessage* message)
{
BTranslatorRoster* roster = BTranslatorRoster::Default();
BPath path;
status_t status = find_directory(B_USER_ADDONS_DIRECTORY, &path, true);
if (status != B_OK) {
_InstallError("translator", status);
return;
}
BDirectory target;
status = target.SetTo(path.Path());
if (status == B_OK) {
if (!target.Contains("Translators"))
status = target.CreateDirectory("Translators", &target);
else
status = target.SetTo(&target, "Translators");
}
if (status != B_OK) {
_InstallError("translator", status);
return;
}
int32 i = 0;
entry_ref ref;
while (message->FindRef("refs", i++, &ref) == B_OK) {
if (!roster->IsTranslator(&ref)) {
_NoTranslatorError(ref.name);
continue;
}
BEntry entry(&ref, true);
status = entry.InitCheck();
if (status != B_OK) {
_InstallError(ref.name, status);
continue;
}
if (target.Contains(ref.name)) {
BString string(
B_TRANSLATE("An item named '%name' already exists in the "
"Translators folder! Shall the existing translator be "
"overwritten?"));
string.ReplaceAll("%name", ref.name);
BAlert* alert = new BAlert(B_TRANSLATE("DataTranslations - Note"),
string.String(), B_TRANSLATE("Cancel"),
B_TRANSLATE("Overwrite"));
alert->SetShortcut(0, B_ESCAPE);
if (alert->Go() != 1)
continue;
// the original file will be replaced
}
// find out whether we need to copy it or not
status = _Install(target, entry);
if (status == B_OK) {
BAlert* alert = new BAlert(B_TRANSLATE("DataTranslations - Note"),
B_TRANSLATE("The new translator has been installed "
"successfully."), B_TRANSLATE("OK"));
alert->Go(NULL);
} else
_InstallError(ref.name, status);
}
}
示例13: B_TRANSLATE
// GetName
void
PathCommand::GetName(BString& name)
{
name << B_TRANSLATE("<modify path>");
}
示例14: BWindow
AttributeWindow::AttributeWindow(FileTypesWindow* target, BMimeType& mimeType,
AttributeItem* attributeItem)
:
BWindow(BRect(100, 100, 350, 200), B_TRANSLATE("Attribute"),
B_MODAL_WINDOW_LOOK, B_MODAL_SUBSET_WINDOW_FEEL,
B_NOT_ZOOMABLE | B_AUTO_UPDATE_SIZE_LIMITS | B_ASYNCHRONOUS_CONTROLS),
fTarget(target),
fMimeType(mimeType.Type())
{
float padding = be_control_look->DefaultItemSpacing();
if (attributeItem != NULL)
fAttribute = *attributeItem;
fPublicNameControl = new BTextControl(B_TRANSLATE("Attribute name:"),
fAttribute.PublicName(), NULL);
fPublicNameControl->SetModificationMessage(
new BMessage(kMsgAttributeUpdated));
fPublicNameControl->SetAlignment(B_ALIGN_RIGHT, B_ALIGN_LEFT);
fAttributeControl = new BTextControl(B_TRANSLATE("Internal name:"),
fAttribute.Name(), NULL);
fAttributeControl->SetModificationMessage(
new BMessage(kMsgAttributeUpdated));
fAttributeControl->SetAlignment(B_ALIGN_RIGHT, B_ALIGN_LEFT);
// filter out invalid characters that can't be part of an attribute
BTextView* textView = fAttributeControl->TextView();
const char* disallowedCharacters = "/";
for (int32 i = 0; disallowedCharacters[i]; i++) {
textView->DisallowChar(disallowedCharacters[i]);
}
fTypeMenu = new BPopUpMenu("type");
BMenuItem* item = NULL;
for (int32 i = 0; kTypeMap[i].name != NULL; i++) {
BMessage* message = new BMessage(kMsgTypeChosen);
message->AddInt32("type", kTypeMap[i].type);
item = new BMenuItem(kTypeMap[i].name, message);
fTypeMenu->AddItem(item);
if (kTypeMap[i].type == fAttribute.Type())
item->SetMarked(true);
}
BMenuField* typeMenuField = new BMenuField("types" , B_TRANSLATE("Type:"),
fTypeMenu);
typeMenuField->SetAlignment(B_ALIGN_RIGHT);
// we must set the color manually when adding a menuField directly
// into a window.
typeMenuField->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
typeMenuField->SetLowColor(ui_color(B_PANEL_BACKGROUND_COLOR));
fVisibleCheckBox = new BCheckBox("visible", B_TRANSLATE("Visible"),
new BMessage(kMsgVisibilityChanged));
fVisibleCheckBox->SetValue(fAttribute.Visible());
BMenu* menu = new BPopUpMenu("display as");
for (int32 i = 0; kDisplayAsMap[i].name != NULL; i++) {
BMessage* message = new BMessage(kMsgDisplayAsChosen);
if (kDisplayAsMap[i].identifier != NULL) {
message->AddString("identifier", kDisplayAsMap[i].identifier);
for (int32 j = 0; kDisplayAsMap[i].supported[j]; j++) {
message->AddInt32("supports", kDisplayAsMap[i].supported[j]);
}
}
item = new BMenuItem(kDisplayAsMap[i].name, message);
menu->AddItem(item);
if (compare_display_as(kDisplayAsMap[i].identifier,
fAttribute.DisplayAs()))
item->SetMarked(true);
}
fDisplayAsMenuField = new BMenuField("display as",
B_TRANSLATE_COMMENT("Display as:",
"Tracker offers different display modes for attributes."), menu);
fDisplayAsMenuField->SetAlignment(B_ALIGN_RIGHT);
fEditableCheckBox = new BCheckBox("editable",
B_TRANSLATE_COMMENT("Editable",
"If Tracker allows to edit this attribute."),
new BMessage(kMsgAttributeUpdated));
fEditableCheckBox->SetValue(fAttribute.Editable());
fSpecialControl = new BTextControl(B_TRANSLATE("Special:"),
display_as_parameter(fAttribute.DisplayAs()), NULL);
fSpecialControl->SetModificationMessage(
new BMessage(kMsgAttributeUpdated));
fSpecialControl->SetAlignment(B_ALIGN_RIGHT, B_ALIGN_LEFT);
fSpecialControl->SetEnabled(false);
char text[64];
snprintf(text, sizeof(text), "%ld", fAttribute.Width());
fWidthControl = new BTextControl(B_TRANSLATE_COMMENT("Width:",
"Default column width in Tracker for this attribute."),
text, NULL);
fWidthControl->SetModificationMessage(
//.........这里部分代码省略.........
示例15: BWindow
SudokuWindow::SudokuWindow()
:
BWindow(BRect(-1, -1, 400, 420), B_TRANSLATE_SYSTEM_NAME("Sudoku"),
B_TITLED_WINDOW, B_ASYNCHRONOUS_CONTROLS | B_QUIT_ON_WINDOW_CLOSE),
fGenerator(NULL),
fStoredState(NULL),
fExportFormat(kExportAsText)
{
BMessage settings;
_LoadSettings(settings);
BRect frame;
if (settings.FindRect("window frame", &frame) == B_OK) {
MoveTo(frame.LeftTop());
ResizeTo(frame.Width(), frame.Height());
frame.OffsetTo(B_ORIGIN);
} else {
float scaling = std::max(1.0f, be_plain_font->Size() / 12.0f);
ResizeTo(Frame().Width() * scaling, Frame().Height() * scaling);
frame = Bounds();
}
MoveOnScreen();
if (settings.HasMessage("stored state")) {
fStoredState = new BMessage;
if (settings.FindMessage("stored state", fStoredState) != B_OK) {
delete fStoredState;
fStoredState = NULL;
}
}
int32 level = 0;
settings.FindInt32("level", &level);
// create GUI
BMenuBar* menuBar = new BMenuBar(Bounds(), "menu");
AddChild(menuBar);
frame.top = menuBar->Frame().bottom;
BView* top = new BView(frame, NULL, B_FOLLOW_ALL, B_WILL_DRAW);
top->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
AddChild(top);
fSudokuView = new SudokuView(
top->Bounds().InsetByCopy(10, 10).OffsetToSelf(0, 0),
"sudoku view", settings, B_FOLLOW_NONE);
CenteredViewContainer* container = new CenteredViewContainer(fSudokuView,
top->Bounds().InsetByCopy(10, 10),
"center", B_FOLLOW_ALL);
container->SetHighColor(top->ViewColor());
top->AddChild(container);
// add menu
// "File" menu
BMenu* menu = new BMenu(B_TRANSLATE("File"));
fNewMenu = new BMenu(B_TRANSLATE("New"));
menu->AddItem(new BMenuItem(fNewMenu, new BMessage(kMsgGenerateSudoku)));
fNewMenu->Superitem()->SetShortcut('N', B_COMMAND_KEY);
BMessage* message = new BMessage(kMsgGenerateSudoku);
message->AddInt32("level", kEasyLevel);
fNewMenu->AddItem(new BMenuItem(B_TRANSLATE("Easy"), message));
message = new BMessage(kMsgGenerateSudoku);
message->AddInt32("level", kAdvancedLevel);
fNewMenu->AddItem(new BMenuItem(B_TRANSLATE("Advanced"), message));
message = new BMessage(kMsgGenerateSudoku);
message->AddInt32("level", kHardLevel);
fNewMenu->AddItem(new BMenuItem(B_TRANSLATE("Hard"), message));
fNewMenu->AddSeparatorItem();
fNewMenu->AddItem(new BMenuItem(B_TRANSLATE("Blank"),
new BMessage(kMsgNewBlank)));
menu->AddItem(new BMenuItem(B_TRANSLATE("Start again"),
new BMessage(kMsgStartAgain)));
menu->AddSeparatorItem();
BMenu* recentsMenu = BRecentFilesList::NewFileListMenu(
B_TRANSLATE("Open file" B_UTF8_ELLIPSIS), NULL, NULL, this, 10, false,
NULL, kSignature);
BMenuItem *item;
menu->AddItem(item = new BMenuItem(recentsMenu,
new BMessage(kMsgOpenFilePanel)));
item->SetShortcut('O', B_COMMAND_KEY);
menu->AddSeparatorItem();
BMenu* subMenu = new BMenu(B_TRANSLATE("Export as" B_UTF8_ELLIPSIS));
message = new BMessage(kMsgExportAs);
message->AddInt32("as", kExportAsText);
subMenu->AddItem(new BMenuItem(B_TRANSLATE("Text"), message));
message= new BMessage(kMsgExportAs);
message->AddInt32("as", kExportAsHTML);
subMenu->AddItem(new BMenuItem(B_TRANSLATE("HTML"), message));
menu->AddItem(subMenu);
menu->AddItem(item = new BMenuItem(B_TRANSLATE("Copy"),
//.........这里部分代码省略.........