本文整理汇总了C++中BPopUpMenu::ItemAt方法的典型用法代码示例。如果您正苦于以下问题:C++ BPopUpMenu::ItemAt方法的具体用法?C++ BPopUpMenu::ItemAt怎么用?C++ BPopUpMenu::ItemAt使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BPopUpMenu
的用法示例。
在下文中一共展示了BPopUpMenu::ItemAt方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: BMessage
Renamer_Remove::Renamer_Remove()
: Renamer()
{
fName = B_TRANSLATE("Remove");
fPosition1 = new BSpinner(NULL, B_TRANSLATE("Remove from position"),
new BMessage(MSG_RENAME_SETTINGS));
fPosition1->SetMinValue(0);
fPosition1->SetValue(0);
BPopUpMenu* myMenu;
myMenu = new BPopUpMenu(B_TRANSLATE("Please select"));
myMenu->AddItem(new BMenuItem(B_TRANSLATE("from the front (left)"),
new BMessage(MSG_RENAME_SETTINGS)));
myMenu->AddItem(new BMenuItem(B_TRANSLATE("from the back (right)"),
new BMessage(MSG_RENAME_SETTINGS)));
myMenu->ItemAt(0)->SetMarked(true);
fDirection1 = new BMenuField(NULL, NULL, myMenu);
fPosition2 = new BSpinner(NULL, B_TRANSLATE("To position"),
new BMessage(MSG_RENAME_SETTINGS));
fPosition2->SetMinValue(0);
fPosition2->SetValue(0);
myMenu = new BPopUpMenu(B_TRANSLATE("Please select"));
myMenu->AddItem(new BMenuItem(B_TRANSLATE("from the front (left)"),
new BMessage(MSG_RENAME_SETTINGS)));
myMenu->AddItem(new BMenuItem(B_TRANSLATE("from the back (right)"),
new BMessage(MSG_RENAME_SETTINGS)));
myMenu->ItemAt(0)->SetMarked(true);
fDirection2 = new BMenuField(NULL, NULL, myMenu);
BLayoutBuilder::Group<>(this, B_VERTICAL)
.SetInsets(B_USE_WINDOW_INSETS)
.AddGroup(B_HORIZONTAL)
.Add(fPosition1)
.Add(fDirection1)
.End()
.AddGroup(B_HORIZONTAL)
.Add(fPosition2)
.Add(fDirection2)
.End()
.AddGlue();
}
示例2: InitFeelMenu
//------------------------------------------------------------------------------
void WindowEditor::InitFeelMenu()
{
BPopUpMenu* menu = new BPopUpMenu("Normal");
BMessage* msg;
for (int i = 0; WindowFeels[i].label; ++i)
{
msg = new BMessage(MSG_WINDOW_SET_FEEL);
msg->AddInt32("newfeel", WindowFeels[i].message);
menu->AddItem(new BMenuItem(WindowFeels[i].label, msg));
}
#if 0
msg->AddInt32("newfeel",B_NORMAL_WINDOW_FEEL);
menu->AddItem(new BMenuItem("Normal",msg));
msg = new BMessage(MSG_WINDOW_SET_FEEL);
msg->AddInt32("newfeel",B_MODAL_APP_WINDOW_FEEL);
menu->AddItem(new BMenuItem("Modal Across Application",msg));
msg = new BMessage(MSG_WINDOW_SET_FEEL);
msg->AddInt32("newfeel",B_MODAL_ALL_WINDOW_FEEL);
menu->AddItem(new BMenuItem("Modal Across System",msg));
msg = new BMessage(MSG_WINDOW_SET_FEEL);
msg->AddInt32("newfeel",B_FLOATING_APP_WINDOW_FEEL);
menu->AddItem(new BMenuItem("Floating Across Application",msg));
msg = new BMessage(MSG_WINDOW_SET_FEEL);
msg->AddInt32("newfeel",B_FLOATING_ALL_WINDOW_FEEL);
menu->AddItem(new BMenuItem("Floating Across System",msg));
#endif
switch (fWindowInfo.feel)
{
case B_NORMAL_WINDOW_FEEL:
menu->ItemAt(0)->SetMarked(true);
break;
case B_MODAL_APP_WINDOW_FEEL:
menu->ItemAt(1)->SetMarked(true);
break;
case B_MODAL_SUBSET_WINDOW_FEEL:
menu->ItemAt(1)->SetMarked(true);
break;
case B_MODAL_ALL_WINDOW_FEEL:
menu->ItemAt(2)->SetMarked(true);
break;
case B_FLOATING_APP_WINDOW_FEEL:
menu->ItemAt(3)->SetMarked(true);
break;
case B_FLOATING_SUBSET_WINDOW_FEEL:
menu->ItemAt(3)->SetMarked(true);
break;
case B_FLOATING_ALL_WINDOW_FEEL:
menu->ItemAt(4)->SetMarked(true);
break;
}
fFeelField = new BMenuField(BRect(10,70,240,90),"look","Window Behavior: ",menu);
fFeelField->SetDivider(be_plain_font->StringWidth("Window Behavior: "));
AddChild(fFeelField);
}
示例3: BPopUpMenu
BPopUpMenu*
TPrefsWindow::_BuildFontMenu(BFont* font)
{
font_family def_family;
font_style def_style;
font_family f_family;
font_style f_style;
BPopUpMenu *menu = new BPopUpMenu("");
font->GetFamilyAndStyle(&def_family, &def_style);
int32 family_menu_index = 0;
int family_count = count_font_families();
for (int family_loop = 0; family_loop < family_count; family_loop++) {
get_font_family(family_loop, &f_family);
BMenu *family_menu = new BMenu(f_family);
int style_count = count_font_styles(f_family);
for (int style_loop = 0; style_loop < style_count; style_loop++) {
get_font_style(f_family, style_loop, &f_style);
BMessage *msg = new BMessage(P_FONT);
msg->AddString("font", f_family);
msg->AddString("style", f_style);
// we send this to make setting the Family easier when things
// change
msg->AddInt32("parent_index", family_menu_index);
BMenuItem *item = new BMenuItem(f_style, msg);
family_menu->AddItem(item);
if ((strcmp(def_family, f_family) == 0)
&& (strcmp(def_style, f_style) == 0)) {
item->SetMarked(true);
}
item->SetTarget(this);
}
menu->AddItem(family_menu);
BMenuItem *item = menu->ItemAt(family_menu_index);
BMessage *msg = new BMessage(P_FONT);
msg->AddString("font", f_family);
item->SetMessage(msg);
item->SetTarget(this);
if (strcmp(def_family, f_family) == 0)
item->SetMarked(true);
family_menu_index++;
}
return menu;
}
示例4: InitLookMenu
//------------------------------------------------------------------------------
void WindowEditor::InitLookMenu()
{
BPopUpMenu *menu = new BPopUpMenu("Document Window");
BMessage *msg;
for (int i = 0; WindowLooks[i].label; ++i)
{
msg = new BMessage(MSG_WINDOW_SET_LOOK);
msg->AddInt32("newlook", WindowLooks[i].message);
menu->AddItem(new BMenuItem(WindowLooks[i].label, msg));
}
#if 0
msg = new BMessage(MSG_WINDOW_SET_LOOK);
msg->AddInt32("newlook",B_TITLED_WINDOW_LOOK);
menu->AddItem(new BMenuItem("Titled Window",msg));
msg = new BMessage(MSG_WINDOW_SET_LOOK);
msg->AddInt32("newlook",B_FLOATING_WINDOW_LOOK);
menu->AddItem(new BMenuItem("Floating Window",msg));
msg = new BMessage(MSG_WINDOW_SET_LOOK);
msg->AddInt32("newlook",B_MODAL_WINDOW_LOOK);
menu->AddItem(new BMenuItem("Modal Window",msg));
msg = new BMessage(MSG_WINDOW_SET_LOOK);
msg->AddInt32("newlook",B_BORDERED_WINDOW_LOOK);
menu->AddItem(new BMenuItem("Bordered Window",msg));
msg = new BMessage(MSG_WINDOW_SET_LOOK);
msg->AddInt32("newlook",B_NO_BORDER_WINDOW_LOOK);
menu->AddItem(new BMenuItem("Borderless Window",msg));
#endif
switch (fWindowInfo.look)
{
case B_DOCUMENT_WINDOW_LOOK:
menu->ItemAt(0)->SetMarked(true);
break;
case B_TITLED_WINDOW_LOOK:
menu->ItemAt(1)->SetMarked(true);
break;
case B_FLOATING_WINDOW_LOOK:
menu->ItemAt(2)->SetMarked(true);
break;
case B_MODAL_WINDOW_LOOK:
menu->ItemAt(3)->SetMarked(true);
break;
case B_BORDERED_WINDOW_LOOK:
menu->ItemAt(4)->SetMarked(true);
break;
case B_NO_BORDER_WINDOW_LOOK:
menu->ItemAt(5)->SetMarked(true);
break;
}
fLookField = new BMenuField(BRect(10,40,240,60),"look","Window Look: ",menu);
fLookField->SetDivider(be_plain_font->StringWidth("Window Look: "));
AddChild(fLookField);
}
示例5: BPopUpMenu
/*static*/ BMenu*
AppearancePrefView::_MakeFontMenu(uint32 command,
const char* defaultFamily, const char* defaultStyle)
{
BPopUpMenu* menu = new BPopUpMenu("");
int32 numFamilies = count_font_families();
uint32 flags;
for (int32 i = 0; i < numFamilies; i++) {
font_family family;
if (get_font_family(i, &family, &flags) == B_OK) {
BFont font;
font_style style;
int32 numStyles = count_font_styles(family);
for (int32 j = 0; j < numStyles; j++) {
if (get_font_style(family, j, &style) == B_OK) {
font.SetFamilyAndStyle(family, style);
if (IsFontUsable(font)) {
BMessage* message = new BMessage(command);
const char* size
= PrefHandler::Default()->getString(PREF_HALF_FONT_SIZE);
message->AddString("font_family", family);
message->AddString("font_style", style);
message->AddString("font_size", size);
char fontMenuLabel[134];
snprintf(fontMenuLabel, sizeof(fontMenuLabel),
"%s - %s", family, style);
BMenu* fontSizeMenu = _MakeFontSizeMenu(fontMenuLabel,
MSG_HALF_FONT_CHANGED, family, style, size);
BMenuItem* item = new BMenuItem(fontSizeMenu, message);
menu->AddItem(item);
if (strcmp(defaultFamily, family) == 0
&& strcmp(defaultStyle, style) == 0)
item->SetMarked(true);
}
}
}
}
}
if (menu->FindMarked() == NULL)
menu->ItemAt(0)->SetMarked(true);
return menu;
}
示例6: BMessage
//.........这里部分代码省略.........
}
if (count > 0)
menu->AddSeparatorItem();
}
// Hack for R5's buggy Query Notification
#ifdef HAIKU_TARGET_PLATFORM_BEOS
menu->AddItem(new BMenuItem(
MDR_DIALECT_CHOICE("Refresh New Mail Count",
"未読メールカウントを更新"),
new BMessage(MD_REFRESH_QUERY)));
#endif
// The New E-mail query
if (fNewMessages > 0) {
BString string;
MDR_DIALECT_CHOICE(
string << fNewMessages << " new message"
<< (fNewMessages != 1 ? "s" : B_EMPTY_STRING),
string << fNewMessages << " 通の未読メッセージ");
_GetNewQueryRef(ref);
item = new BMenuItem(navMenu = new BNavMenu(string.String(),
B_REFS_RECEIVED, BMessenger(kTrackerSignature)),
msg = new BMessage(B_REFS_RECEIVED));
msg->AddRef("refs", &ref);
navMenu->SetNavDir(&ref);
menu->AddItem(item);
} else {
menu->AddItem(item = new BMenuItem(
MDR_DIALECT_CHOICE ("No new messages","未読メッセージなし"), NULL));
item->SetEnabled(false);
}
BMailAccounts accounts;
if (modifiers() & B_SHIFT_KEY) {
BMenu *accountMenu = new BMenu(
MDR_DIALECT_CHOICE ("Check for mails only","R) メール受信のみ"));
BFont font;
menu->GetFont(&font);
accountMenu->SetFont(&font);
for (int32 i = 0; i < accounts.CountAccounts(); i++) {
BMailAccountSettings* account = accounts.AccountAt(i);
BMessage* message = new BMessage(MD_CHECK_FOR_MAILS);
message->AddInt32("account", account->AccountID());
accountMenu->AddItem(new BMenuItem(account->Name(), message));
}
if (accounts.CountAccounts() == 0) {
item = new BMenuItem("<no accounts>", NULL);
item->SetEnabled(false);
accountMenu->AddItem(item);
}
accountMenu->SetTargetForItems(this);
menu->AddItem(new BMenuItem(accountMenu,
new BMessage(MD_CHECK_FOR_MAILS)));
// Not used:
// menu->AddItem(new BMenuItem(MDR_DIALECT_CHOICE (
// "Check For Mails Only","メール受信のみ"), new BMessage(MD_CHECK_FOR_MAILS)));
menu->AddItem(new BMenuItem(
MDR_DIALECT_CHOICE ("Send pending mails", "M) 保留メールを送信"),
new BMessage(MD_SEND_MAILS)));
} else {
menu->AddItem(item = new BMenuItem(
MDR_DIALECT_CHOICE ("Check for mail now", "C) メールチェック"),
new BMessage(MD_CHECK_SEND_NOW)));
if (accounts.CountAccounts() == 0)
item->SetEnabled(false);
}
menu->AddSeparatorItem();
menu->AddItem(new BMenuItem(
MDR_DIALECT_CHOICE ("Preferences", "P) メール環境設定") B_UTF8_ELLIPSIS,
new BMessage(MD_OPEN_PREFS)));
if (modifiers() & B_SHIFT_KEY) {
menu->AddItem(new BMenuItem(
MDR_DIALECT_CHOICE ("Shutdown mail services", "Q) 終了"),
new BMessage(B_QUIT_REQUESTED)));
}
// Reset Item Targets (only those which aren't already set)
for (int32 i = menu->CountItems(); i-- > 0;) {
item = menu->ItemAt(i);
if (item && (msg = item->Message()) != NULL) {
if (msg->what == B_REFS_RECEIVED)
item->SetTarget(tracker);
else
item->SetTarget(this);
}
}
return menu;
}
示例7: messenger
ProjectSettingsWindow::ProjectSettingsWindow(BRect frame, Project* project)
:
BWindow(frame, TR("Project settings"), B_TITLED_WINDOW,
B_NOT_ZOOMABLE | B_NOT_RESIZABLE | B_AUTO_UPDATE_SIZE_LIMITS),
fProject(project),
fDirty(false)
{
if (fProject == NULL)
debugger("Bad project given to Project Settings window");
fRefFilter = new TypedRefFilter(NULL, B_DIRECTORY_NODE);
BMessenger messenger(this);
entry_ref projectFolderRef;
BEntry(fProject->GetPath().GetFolder()).GetRef(&projectFolderRef);
fFilePanel = new BFilePanel(B_OPEN_PANEL, &messenger, &projectFolderRef,
B_DIRECTORY_NODE, true, new BMessage(M_ADD_PATH), fRefFilter);
fAutolock = new BAutolock(fProject);
AddCommonFilter(new EscapeCancelFilter());
fTargetText = new AutoTextControl("targetname", TR("Target name:"),
fProject->GetTargetName(), new BMessage(M_TARGET_NAME_CHANGED));
BPopUpMenu* targetTypeMenu = new BPopUpMenu(TR("Target type"));
targetTypeMenu->AddItem(new BMenuItem(TR("Application"),
new BMessage(M_SET_TARGET_TYPE)));
targetTypeMenu->AddItem(new BMenuItem(TR("Shared library"),
new BMessage(M_SET_TARGET_TYPE)));
targetTypeMenu->AddItem(new BMenuItem(TR("Static library"),
new BMessage(M_SET_TARGET_TYPE)));
targetTypeMenu->AddItem(new BMenuItem(TR("Device driver"),
new BMessage(M_SET_TARGET_TYPE)));
fTypeField = new BMenuField("type", TR("Target type:"), targetTypeMenu);
SetToolTip(fTypeField, TR("The kind of program you want to build"));
BMenuItem* item = targetTypeMenu->ItemAt(fProject->TargetType());
if (item != NULL)
item->SetMarked(true);
fIncludeList = new IncludeList(fProject->GetPath().GetFolder());
SetToolTip(fIncludeList,
TR("The folders you want Paladin to search for header files"));
BScrollView* includeScrollView = new BScrollView("includescrollview",
fIncludeList, B_WILL_DRAW, true, true);
includeScrollView->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
includeScrollView->SetExplicitMinSize(
BSize(be_plain_font->StringWidth("M") * 34.0f,
be_plain_font->StringWidth("M") * 12.0f));
for (int32 i = 0; i < fProject->CountLocalIncludes(); i++) {
fIncludeList->AddItem(new BStringItem(
fProject->LocalIncludeAt(i).Relative().String()));
}
float buttonWidth = be_plain_font->StringWidth("+") * 2.0f + 3.0f;
BButton* addButton = new BButton("addbutton", TR("+"),
new BMessage(M_SHOW_ADD_PATH));
addButton->SetExplicitSize(BSize(buttonWidth, buttonWidth));
addButton->SetToolTip(TR("Add a file to the include path list"));
BButton* removeButton = new BButton("removebutton", TR("−"),
new BMessage(M_REMOVE_PATH));
removeButton->SetExplicitSize(BSize(buttonWidth, buttonWidth));
removeButton->SetToolTip(TR("Remove the selected path"));
// general tab
fGeneralView = new BView(TR("General"), B_WILL_DRAW);
fGeneralView->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
BLayoutBuilder::Group<>(fGeneralView, B_VERTICAL, 0)
.AddGrid(B_USE_DEFAULT_SPACING, B_USE_SMALL_SPACING)
.Add(fTargetText->CreateLabelLayoutItem(), 0, 0)
.Add(fTargetText->CreateTextViewLayoutItem(), 1, 0)
.Add(fTypeField->CreateLabelLayoutItem(), 0, 1)
.AddGroup(B_HORIZONTAL, B_USE_DEFAULT_SPACING, 1, 1)
.Add(fTypeField->CreateMenuBarLayoutItem())
.AddGlue()
.End()
.End()
.AddStrut(B_USE_DEFAULT_SPACING)
.AddGroup(B_VERTICAL, 2.0f)
.Add(new BStringView("include paths", TR("Include paths:")))
.AddGroup(B_HORIZONTAL, B_USE_SMALL_SPACING)
.Add(includeScrollView)
.AddGroup(B_VERTICAL, B_USE_SMALL_SPACING)
.Add(addButton)
.Add(removeButton)
.AddGlue()
.End()
.End()
.End()
.SetInsets(B_USE_DEFAULT_SPACING)
.End();
//.........这里部分代码省略.........
示例8: TR
//.........这里部分代码省略.........
fTabs[0] = BLayoutBuilder::Grid<>(B_USE_DEFAULT_SPACING, B_USE_SMALL_SPACING)
.Add(new BStringView("projects folder label", TR("Projects folder:")), 0, 0)
.Add(fProjectFolder, 1, 0)
.AddGroup(B_VERTICAL, 0.0f, 1, 1)
.Add(fShowProjectFolder)
.Add(fDontAddHeaders)
.End()
.Add(buildBox, 1, 2)
.Add(fAutoSyncModules, 1, 3)
.Add(new BStringView("backups folder label", TR("Backups folder:")), 0, 4)
.Add(fBackupFolder, 1, 4)
.SetInsets(B_USE_DEFAULT_SPACING)
.View();
fTabs[0]->SetName(TR("General"));
fTabs[0]->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
#ifndef BUILD_CODE_LIBRARY
fAutoSyncModules->Hide();
#endif
// source control
BPopUpMenu* scmMenu = new BPopUpMenu("SCM Chooser");
scmMenu->AddItem(new BMenuItem(TR("None"), NULL));
scmMenu->AddSeparatorItem();
scmMenu->AddItem(new BMenuItem(TR("Git"), NULL));
scmMenu->AddItem(new BMenuItem(TR("Mercurial"), NULL));
scmMenu->AddItem(new BMenuItem(TR("Subversion"), NULL));
fSCMChooser = new BMenuField("scmchooser", TR("Preferred source control:"),
scmMenu);
#ifdef DISABLE_GIT_SUPPORT
scmMenu->ItemAt(2)->SetEnabled(false);
#endif
BMenuItem* marked = scmMenu->ItemAt(gDefaultSCM);
if (marked != NULL)
marked->SetMarked(true);
else
scmMenu->ItemAt(0)->SetMarked(true);
if (!marked->IsEnabled()) {
// if the default SCM is disabled unmark it and mark the first one that
// is enabled.
marked->SetMarked(false);
for (int32 i = 0; i < scmMenu->CountItems(); i++) {
if (scmMenu->ItemAt(i)->IsEnabled()) {
scmMenu->ItemAt(i)->SetMarked(true);
break;
}
}
}
fSVNRepoFolder = new PathBox("svnrepofolder", gSVNRepoPath.GetFullPath(), "");
fSVNRepoFolder->MakeValidating(true);
SetToolTip(fSVNRepoFolder, TR("Sets the location for the 'server' side of "
"local Subversion repositories."));
fTabs[1] = BLayoutBuilder::Group<>(B_VERTICAL)
.AddGrid(B_USE_DEFAULT_SPACING, B_USE_SMALL_SPACING)
.Add(fSCMChooser->CreateLabelLayoutItem(), 0, 0)
.AddGroup(B_HORIZONTAL, B_USE_DEFAULT_SPACING, 1, 0)
.Add(fSCMChooser->CreateMenuBarLayoutItem())
.AddGlue()
.End()
.Add(new BStringView("svn repo folder label",
TR("Subversion repository folder:")), 0, 1)
.Add(fSVNRepoFolder, 1, 1)
.End()
.AddGlue()
.SetInsets(B_USE_DEFAULT_SPACING)
.View();
fTabs[1]->SetName(TR("Source control"));
fTabs[1]->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
// tab view
fTabView = new BTabView("tabview", B_WIDTH_FROM_LABEL);
fTabView->SetBorder(B_NO_BORDER);
fTabView->AddTab(fTabs[0]);
fTabView->AddTab(fTabs[1]);
fTabView->Select(0L);
BLayoutBuilder::Group<>(this, B_VERTICAL, 0)
.AddStrut(B_USE_SMALL_SPACING)
.Add(fTabView)
.End();
fProjectFolder->MakeFocus(true);
CenterOnScreen();
}
示例9: BWindow
ResizeWindow::ResizeWindow (CanvasWindow *target, const char *title, int32 _h, int32 _w)
: BWindow (BRect (100, 100, 300, 248), title, B_TITLED_WINDOW, B_NOT_RESIZABLE)
{
char hS[16], wS[16], rD[16];
fTarget = target;
fRez = 72;
fH = _w;
fV = _h;
fHUnit = UNIT_PIXELS;
fVUnit = UNIT_PIXELS;
BRect bgFrame, cancelFrame, openFrame, textFrame, heightFrame, widthFrame, rezFrame;
bgFrame = Bounds();
BView *bg = new BView (bgFrame, "SW bg", B_FOLLOW_ALL, B_WILL_DRAW);
bg->SetViewColor (LightGrey);
AddChild (bg);
textFrame.Set (8, 8, 192, 102);
BBox *text = new BBox (textFrame, "SW box");
text->SetLabel (lstring (180, "Canvas Size"));
bg->AddChild (text);
#if 0
textFrame.Set (8, 80, 192, 120);
BBox *rez = new BBox (textFrame, "SW r box");
rez->SetLabel (lstring (186, "Resolution"));
bg->AddChild (rez);
#endif
sprintf (hS, "%li", _h);
sprintf (wS, "%li", _w);
sprintf (rD, "%li", fRez);
widthFrame.Set (8, 15, 120, 33);
heightFrame.Set (8, 39, 120, 57);
rezFrame.Set (8, 63, 120, 81);
newWidth = new BTextControl (widthFrame, "NewWidth", lstring (181, "Width"), wS, new BMessage ('Swdt'));
newHeight = new BTextControl (heightFrame, "NewHeight", lstring (182, "Height"), hS, new BMessage ('Shgt'));
rDPI = new BTextControl (rezFrame, "rez", lstring (186, "Resolution"), rD, new BMessage ('Srez'));
newHeight->SetAlignment (B_ALIGN_RIGHT, B_ALIGN_LEFT);
newWidth->SetAlignment (B_ALIGN_RIGHT, B_ALIGN_LEFT);
rDPI->SetAlignment (B_ALIGN_RIGHT, B_ALIGN_LEFT);
BStringView *dpiV = new BStringView (BRect (rezFrame.right + 4, rezFrame.top, rezFrame.right + 40, rezFrame.bottom),
"dpiV", "dpi");
BPopUpMenu *hPU = new BPopUpMenu ("");
hPU->AddItem (new BMenuItem (lstring (187, "pixels"), new BMessage ('h_px')));
hPU->AddItem (new BMenuItem (lstring (188, "in"), new BMessage ('h_in')));
hPU->AddItem (new BMenuItem (lstring (189, "cm"), new BMessage ('h_cm')));
hPU->ItemAt(0)->SetMarked (true);
BMenuField *hMF = new BMenuField (BRect (124, 14, 180, 30), "hUnit", NULL, hPU);
BPopUpMenu *vPU = new BPopUpMenu ("");
vPU->AddItem (new BMenuItem (lstring (187, "pixels"), new BMessage ('v_px')));
vPU->AddItem (new BMenuItem (lstring (188, "in"), new BMessage ('v_in')));
vPU->AddItem (new BMenuItem (lstring (189, "cm"), new BMessage ('v_cm')));
vPU->ItemAt(0)->SetMarked (true);
BMenuField *vMF = new BMenuField (BRect (124, 38, 180, 54), "vUnit", NULL, vPU);
text->AddChild (newWidth);
text->AddChild (hMF);
text->AddChild (newHeight);
text->AddChild (vMF);
text->AddChild (rDPI);
text->AddChild (dpiV);
cancelFrame.Set (82, 112, 134, 136);
openFrame.Set (140, 112, 192, 136);
BButton *cancel = new BButton (cancelFrame, "RSW cancel", lstring (131, "Cancel"), new BMessage ('RScn'));
BButton *open = new BButton (openFrame, "RSW ok", lstring (136, "OK"), new BMessage ('RSok'));
open->MakeDefault (true);
bg->AddChild (cancel);
bg->AddChild (open);
fStatus = 0;
}
示例10: scr
QScopeWindow::QScopeWindow() : BWindow(BRect(0, 0, SCOPE_WIDTH+200-1, SCOPE_HEIGHT-1), "QScope", B_TITLED_WINDOW, B_NOT_RESIZABLE)
{
// Move window to right position
Lock();
MoveTo(80, 60);
BRect b = Bounds();
// Look up colors for scope
{
BScreen scr(this);
illumination = false;
c_black = scr.IndexForColor(0, 0, 0);
c_dark_green = scr.IndexForColor(0, 32, 16);
for (int i=0; i<16; i++)
c_beam[i] = scr.IndexForColor(0, 255 - i * 8, 128 - i * 4);
}
// Light gray background
BView *top = new BView(BRect(0, 0, b.right, b.bottom), "top", B_FOLLOW_NONE, B_WILL_DRAW);
AddChild(top);
top->SetViewColor(fill_color);
// Allocate bitmap
the_bitmap = new BBitmap(BRect(0, 0, SCOPE_WIDTH-1, SCOPE_HEIGHT-1), B_COLOR_8_BIT);
// Create bitmap view
main_view = new BitmapView(BRect(0, 0, SCOPE_WIDTH-1, SCOPE_HEIGHT-1), the_bitmap);
top->AddChild(main_view);
// Create interface elements
{
BBox *box = new BBox(BRect(SCOPE_WIDTH + 4, 4, SCOPE_WIDTH + 196, 62));
top->AddChild(box);
box->SetLabel("Input");
BPopUpMenu *popup = new BPopUpMenu("stream popup", true, true);
popup->AddItem(new BMenuItem("DAC", new BMessage(MSG_DAC_STREAM)));
popup->AddItem(new BMenuItem("ADC", new BMessage(MSG_ADC_STREAM)));
popup->SetTargetForItems(this);
popup->ItemAt(0)->SetMarked(true);
BMenuField *menu_field = new BMenuField(BRect(4, 14, 188, 34), "stream", "Stream", popup);
box->AddChild(menu_field);
popup = new BPopUpMenu("channel popup", true, true);
popup->AddItem(new BMenuItem("Left", new BMessage(MSG_LEFT_CHANNEL)));
popup->AddItem(new BMenuItem("Right", new BMessage(MSG_RIGHT_CHANNEL)));
popup->AddItem(new BMenuItem("Stereo", new BMessage(MSG_STEREO_CHANNELS)));
popup->SetTargetForItems(this);
popup->ItemAt(0)->SetMarked(true);
menu_field = new BMenuField(BRect(4, 34, 188, 54), "channel", "Channel", popup);
box->AddChild(menu_field);
}
{
BBox *box = new BBox(BRect(SCOPE_WIDTH + 4, 66, SCOPE_WIDTH + 196, 104));
top->AddChild(box);
box->SetLabel("Time");
BPopUpMenu *popup = new BPopUpMenu("time/div popup", true, true);
popup->AddItem(new BMenuItem("0.1ms", new BMessage(MSG_TIME_DIV_100us)));
popup->AddItem(new BMenuItem("0.2ms", new BMessage(MSG_TIME_DIV_200us)));
popup->AddItem(new BMenuItem("0.5ms", new BMessage(MSG_TIME_DIV_500us)));
popup->AddItem(new BMenuItem("1ms", new BMessage(MSG_TIME_DIV_1ms)));
popup->AddItem(new BMenuItem("2ms", new BMessage(MSG_TIME_DIV_2ms)));
popup->AddItem(new BMenuItem("5ms", new BMessage(MSG_TIME_DIV_5ms)));
popup->AddItem(new BMenuItem("10ms", new BMessage(MSG_TIME_DIV_10ms)));
popup->SetTargetForItems(this);
popup->ItemAt(4)->SetMarked(true);
BMenuField *menu_field = new BMenuField(BRect(4, 14, 188, 34), "time/div", "Time/Div.", popup);
box->AddChild(menu_field);
}
{
BBox *box = new BBox(BRect(SCOPE_WIDTH + 4, 108, SCOPE_WIDTH + 196, 230));
top->AddChild(box);
box->SetLabel("Trigger");
BPopUpMenu *popup = new BPopUpMenu("trigger channel popup", true, true);
popup->AddItem(new BMenuItem("Left", new BMessage(MSG_TRIGGER_LEFT)));
popup->AddItem(new BMenuItem("Right", new BMessage(MSG_TRIGGER_RIGHT)));
popup->SetTargetForItems(this);
popup->ItemAt(0)->SetMarked(true);
BMenuField *menu_field = new BMenuField(BRect(4, 14, 188, 34), "trigger_channel", "Channel", popup);
box->AddChild(menu_field);
popup = new BPopUpMenu("trigger mode popup", true, true);
popup->AddItem(new BMenuItem("Off", new BMessage(MSG_TRIGGER_OFF)));
popup->AddItem(new BMenuItem("Level", new BMessage(MSG_TRIGGER_LEVEL)));
popup->AddItem(new BMenuItem("Peak", new BMessage(MSG_TRIGGER_PEAK)));
popup->SetTargetForItems(this);
popup->ItemAt(1)->SetMarked(true);
menu_field = new BMenuField(BRect(4, 34, 188, 54), "trigger_mode", "Trigger Mode", popup);
box->AddChild(menu_field);
BStringView *label = new BStringView(BRect(5, 54, 97, 73), "", "Level");
box->AddChild(label);
TSliderView *the_slider = new TSliderView(BRect(98, 58, 188, 76), "level", 0.5, trigger_level_callback, this);
box->AddChild(the_slider);
popup = new BPopUpMenu("slope popup", true, true);
//.........这里部分代码省略.........
示例11: windowRect
//.........这里部分代码省略.........
fStatusBar->SetLowUIColor(B_UI_PANEL_BACKGROUND_COLOR);
fStatusBar->SetHighUIColor(B_UI_PANEL_TEXT_COLOR);
#else
fStatusBar->SetViewColor(245, 245, 245, 0);
fStatusBar->SetLowColor(245, 245, 245, 0);
fStatusBar->SetHighColor(0, 0, 0, 0);
#endif
BPopUpMenu *pop = new BPopUpMenu("Protocols", true, true);
fProtocolMenu = new BMenuField(
BRect(kPadding, kPadding, Bounds().bottom - kPadding, 100),
"Field", NULL, pop);
fStatusBar->AddItem(fProtocolMenu);
// fInfoView must be the LAST thing added to fStatusBar, otherwise the
// resizing of it will be all bonkers.
fInfoView = new BStringView(BRect(fProtocolMenu->Frame().right+5, 2,
fStatusBar->Bounds().right - kPadding,
fStatusBar->Bounds().bottom - kPadding), "infoView",
"", B_FOLLOW_LEFT_RIGHT | B_FOLLOW_BOTTOM, B_WILL_DRAW);
fStatusBar->AddItem(fInfoView);
#if B_BEOS_VERSION > B_BEOS_VERSION_5
fInfoView->SetViewUIColor(B_UI_PANEL_BACKGROUND_COLOR);
fInfoView->SetLowUIColor(B_UI_PANEL_BACKGROUND_COLOR);
fInfoView->SetHighUIColor(B_UI_PANEL_TEXT_COLOR);
#else
fInfoView->SetViewColor(245, 245, 245, 0);
fInfoView->SetLowColor(245, 245, 245, 0);
fInfoView->SetHighColor(0, 0, 0, 0);
#endif
// need to build the menu here since it fiddles with fInfoView
BuildProtocolMenu();
BMenuItem *first = pop->ItemAt(0);
if (first) first->SetMarked(true);
BRect resizeRect = Bounds();
resizeRect.top = inputDivider.y + 1;
resizeRect.bottom = inputDivider.y + 4;
fResize = new ResizeView(fInputScroll, resizeRect, "resizer",
B_FOLLOW_BOTTOM | B_FOLLOW_LEFT_RIGHT);
AddChild(fResize);
Theme::TimestampFore = C_TIMESTAMP_DUMMY;
Theme::TimestampBack = C_TIMESTAMP_DUMMY;
Theme::TimespaceFore = MAX_COLORS;
Theme::TimespaceBack = MAX_COLORS;
Theme::TimespaceFont = MAX_FONTS;
Theme::TimestampFont = F_TIMESTAMP_DUMMY;
Theme::NormalFore = C_TEXT;
Theme::NormalBack = C_TEXT;
Theme::NormalFont = F_TEXT;
Theme::SelectionBack = C_SELECTION;
fTheme = new Theme("ChatWindow", MAX_COLORS + 1, MAX_COLORS + 1, MAX_FONTS + 1);
//NormalTextRender *ntr=new NormalTextRender(be_plain_font);
fTheme->WriteLock();
fTheme->SetForeground(C_URL, 5, 5, 150);
fTheme->SetBackground(C_URL, 255, 255, 255);
//fTheme->SetTextRender(C_URL, ntr);
fTheme->SetForeground(C_TIMESTAMP, 130, 130, 130);
fTheme->SetBackground(C_TIMESTAMP, 255, 255, 255);
示例12: templatePath
TemplateWindow::TemplateWindow(const BRect& frame)
:
BWindow(frame, TR("Choose a project type"), B_TITLED_WINDOW,
B_NOT_RESIZABLE | B_NOT_ZOOMABLE | B_AUTO_UPDATE_SIZE_LIMITS)
{
RegisterWindow();
CheckTemplates();
DPath templatePath(gAppPath.GetFolder());
templatePath << TR("Templates");
fTempList.ScanFolder(templatePath.GetFullPath());
// project type
BPopUpMenu* projectTypeMenu = new BPopUpMenu("Project type");
for (int32 i = 0; i < fTempList.CountTemplates(); i++) {
ProjectTemplate* ptemp = fTempList.TemplateAt(i);
entry_ref ref = ptemp->GetRef();
projectTypeMenu->AddItem(new BMenuItem(ref.name,
new BMessage(M_TEMPLATE_SELECTED)));
}
projectTypeMenu->ItemAt(0L)->SetMarked(true);
fTemplateField = new BMenuField("templatefield", TR("Project type: "),
projectTypeMenu);
fTemplateField->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
// project name
fNameBox = new AutoTextControl("namebox", TR("Project name:"), "",
new BMessage(M_NAME_CHANGED));
SetToolTip(fNameBox, TR("The name of your project. "
"It can be the same as the Target name, but it does not have to be."));
// target name
fTargetBox = new AutoTextControl("targetbox", TR("Target name:"), "BeApp",
new BMessage(M_TARGET_CHANGED));
SetToolTip(fTargetBox, TR("The name of the compiled application or library"));
// project path
fPathBox = new PathBox("pathbox", gProjectPath.GetFullPath(), "");
fPathBox->SetExplicitMinSize(BSize(be_plain_font->StringWidth("M") * 36,
B_SIZE_UNSET)),
SetToolTip(fPathBox, TR("Set the location for your project."));
// source control
BPopUpMenu* scmMenu = new BPopUpMenu("SCM Chooser");
scmMenu->AddItem(new BMenuItem(TR("Mercurial"), new BMessage()));
scmMenu->AddItem(new BMenuItem(TR("Git"), new BMessage()));
scmMenu->AddItem(new BMenuItem(TR("Subversion"), new BMessage()));
scmMenu->AddItem(new BMenuItem(TR("None"), new BMessage()));
if (!gHgAvailable) {
scmMenu->ItemAt(0)->SetEnabled(false);
scmMenu->ItemAt(0)->SetLabel(TR("Mercurial unavailable"));
}
if (!gGitAvailable) {
scmMenu->ItemAt(1)->SetEnabled(false);
scmMenu->ItemAt(1)->SetLabel(TR("Git unavailable"));
}
if (!gSvnAvailable) {
scmMenu->ItemAt(2)->SetEnabled(false);
scmMenu->ItemAt(2)->SetLabel(TR("Subversion unavailable"));
}
fSCMChooser = new BMenuField("scmchooser", TR("Source control: "), scmMenu);
fSCMChooser->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
SetToolTip(fSCMChooser,
TR("Choose the source control manager for your project, if any."));
scmMenu->ItemAt(gDefaultSCM)->SetMarked(true);
BMenuItem* item = scmMenu->FindMarked();
if (!item->IsEnabled()) {
item->SetMarked(false);
for (int32 i = 0; i < scmMenu->CountItems(); i++) {
if (scmMenu->ItemAt(i)->IsEnabled()) {
scmMenu->ItemAt(i)->SetMarked(true);
break;
}
}
}
// create folder check box
fCreateFolder = new BCheckBox(TR("Create project folder"));
fCreateFolder->SetValue(B_CONTROL_ON);
SetToolTip(fCreateFolder, TR("If checked, a folder for your project will be created "
"in the folder in the Location box above."));
// create project button
fCreateProjectButton = new BButton("ok", TR("Create project") B_UTF8_ELLIPSIS,
new BMessage(M_CREATE_PROJECT));
fCreateProjectButton->SetEnabled(false);
fCreateProjectButton->MakeDefault(true);
//.........这里部分代码省略.........
示例13:
/*! \brief Updates targets of all controls currently in the view.
* \details BView::AttachToWindow(), among other things, modifies the targets
* of controls to point to main looper of the application. This is
* not desirable way. This function corrects it.
*/
void CalendarModulePreferencesView::UpdateTargetting( void )
{
BCheckBox* tempCheckBox = NULL;
int i, limit;
// Updating calendar chooser part
BMenuItem* menuItem = NULL;
if ( calendarModules ) {
limit = calendarModules->CountItems();
for ( i = 0; i < limit; ++i )
{
menuItem = dynamic_cast< BMenuItem* >( calendarModules->ItemAt( i ) );
if ( menuItem )
menuItem->SetTarget( this );
}
}
// Update Weekends selector box
BBox* tempBBox = ( BBox* )this->FindView( "Weekend selector" );
if ( tempBBox ) {
limit = tempBBox->CountChildren();
for ( i = 0; i < limit; ++i )
{
tempCheckBox = dynamic_cast< BCheckBox* >( tempBBox->ChildAt( i ) );
if ( tempCheckBox )
tempCheckBox->SetTarget( this );
}
}
// Update First day of week chooser
BPopUpMenu* tempMenu = ( BPopUpMenu* )this->FindView( "First day of week" );
if ( tempMenu )
{
limit = tempMenu->CountItems();
for ( i = 0; i < limit; ++i )
{
menuItem = dynamic_cast< BMenuItem* >( tempMenu->ItemAt( i ) );
if ( menuItem )
menuItem->SetTarget( this );
}
}
// Update day-month-year order chooser
tempMenu = ( BPopUpMenu* )this->FindView( "DmyOrderChooser" );
if ( tempMenu )
{
limit = tempMenu->CountItems();
for ( i = 0; i < limit; ++i )
{
menuItem = dynamic_cast< BMenuItem* >( tempMenu->ItemAt( i ) );
if ( menuItem )
menuItem->SetTarget( this );
}
}
// Update the target of Color selector
CategoryListView* catListView = ( CategoryListView* )this->FindView("Colors list view");
if ( catListView )
{
catListView->SetTarget( this );
}
} // <-- end of function CalendarModulePreferencesView::UpdateTargetting
示例14: BPopUpMenu
/*!
* \brief Create a menu to select the module user is setting up.
* \note This is an internal function.
*/
BPopUpMenu* CalendarModulePreferencesView::PopulateModulesMenu( void )
{
BPopUpMenu* toReturn = NULL;
BMenuItem* toAdd = NULL;
BMessage* toSend = NULL;
BString moduleId; // Note: this is not a pointer!
CalendarModule* currentCalModule = NULL;
toReturn = new BPopUpMenu("Calendar Modules");
if ( ! toReturn )
{
/* Panic! */
exit (1);
}
// Looping on all calendar modules available in the system.
for ( uint i=0; i < NUMBER_OF_CALENDAR_MODULES; ++i )
{
// Obtain the next calendar module
currentCalModule = (CalendarModule *)global_ListOfCalendarModules.ItemAt( i );
if ( !currentCalModule )
{
continue; // Skipping unavailable ones
}
// Create the message
toSend = new BMessage( kCalendarModuleChosen );
if ( !toSend )
{
/* Panic! */
exit(1);
}
// Add the ID of the module to the message
moduleId = currentCalModule->Identify();
toSend->AddString( "Module ID", moduleId );
// Create the menu item
toAdd = new BMenuItem( moduleId.String(), toSend );
if ( ! toAdd )
{
/* Panic! */
exit(1);
}
toAdd->SetTarget( this );
// Add the newly created item to the menu
toReturn->AddItem( toAdd );
// Gregorian calendar module is the default one
if ( moduleId == "Gregorian" )
{
toAdd->SetMarked( true );
}
} /* <-- end of "for ( every calendar module )" */
// At least something should be marked.
if ( ( ! toReturn->FindMarked() ) && ( toReturn->CountItems() > 0 ) )
{
toReturn->ItemAt( 0 )->SetMarked( true );
}
return toReturn;
} // <-- end of function "CalendarModulePreferencesView::PopulateModulesMenu"
示例15:
void
TestView::MessageReceived(BMessage *msg)
{
switch (msg->what)
{
case M_TEST_CHOSEN:
{
SetTest(msg);
break;
}
case M_MODE_CHOSEN:
{
BString mode;
if (msg->FindString("mode",&mode) != B_OK)
break;
SetMode(mode.String());
break;
}
case M_VALUE_CHANGED:
{
BString str;
if (fTest->FindString("value",&str) == B_OK)
fTest->ReplaceString("value",fValueBox->Text());
else
fTest->AddString("value",fValueBox->Text());
break;
}
case M_SHOW_TEST_MENU:
{
BPopUpMenu *menu = (BPopUpMenu*)BPopUpMenu::Instantiate(&fArchivedTestMenu);
menu->SetTargetForItems(this);
for (int32 i = 0; i < menu->CountItems(); i++)
{
BMenuItem *item = menu->ItemAt(i);
if (item->Submenu())
item->Submenu()->SetTargetForItems(this);
}
BPoint pt;
uint32 buttons;
GetMouse(&pt,&buttons);
ConvertToScreen(&pt);
pt.x -= 10.0;
if (pt.x < 0.0)
pt.x = 0.0;
pt.y -= 10.0;
if (pt.y < 0.0)
pt.y = 0.0;
menu->SetAsyncAutoDestruct(true);
menu->Go(pt,true,true,true);
break;
}
case M_SHOW_TYPE_MENU:
{
BPopUpMenu *menu = (BPopUpMenu*)BPopUpMenu::Instantiate(&gArchivedTypeMenu);
menu->SetTargetForItems(this);
for (int32 i = 0; i < menu->CountItems(); i++)
{
BMenuItem *item = menu->ItemAt(i);
if (item->Submenu())
item->Submenu()->SetTargetForItems(this);
}
BPoint pt;
uint32 buttons;
GetMouse(&pt,&buttons);
ConvertToScreen(&pt);
pt.x -= 10.0;
if (pt.x < 0.0)
pt.x = 0.0;
pt.y -= 10.0;
if (pt.y < 0.0)
pt.y = 0.0;
menu->SetAsyncAutoDestruct(true);
menu->Go(pt,true,true,true);
break;
}
case M_SHOW_MODE_MENU:
{
ShowModeMenu();
break;
}
default:
{
BView::MessageReceived(msg);
break;
}
}
}