void CFtpDialog::UpdateDirectoryPopup() { BMenu* menu = fDirectoryField->Menu(); BMenuItem *item; while ((item = menu->ItemAt(menu->CountItems() - 1)) != NULL) { menu->RemoveItem(item); delete item; } char p[PATH_MAX], *l; strcpy(p, fPath); l = strtok(p, "/"); menu->AddItem(new BMenuItem("/", new BMessage(msg_SelectedDirectory))); while (l) { menu->AddItem(new BMenuItem(l, new BMessage(msg_SelectedDirectory))); l = strtok(NULL, "/"); } menu->ItemAt(menu->CountItems() - 1)->SetMarked(true); } // CFtpDialog::UpdateDirectoryPopup
/*********************************************************** * SetValue ***********************************************************/ void HCriteriaView::SetValue(int32 attr, int32 operation, const char* attr_value, int32 operation2) { BMenu *menu = fAttrMenu->Menu(); BMenuItem *item; if(menu) { item = menu->ItemAt(attr); if(item) item->SetMarked(true); } menu = fOpMenu->Menu(); if(menu) { item = menu->ItemAt(operation); if(item) item->SetMarked(true); } menu = fOp2Menu->Menu(); if(menu) { item = menu->ItemAt(operation2); if(item) item->SetMarked(true); } fValue->SetText(attr_value); }
void FilterView::AdoptModel(const Model& model) { BMenu* repositoryMenu = fRepositoryField->Menu(); repositoryMenu->RemoveItems(0, repositoryMenu->CountItems(), true); repositoryMenu->AddItem(new BMenuItem(B_TRANSLATE("All depots"), new BMessage(MSG_DEPOT_SELECTED))); repositoryMenu->ItemAt(0)->SetMarked(true); repositoryMenu->AddItem(new BSeparatorItem()); const DepotList& depots = model.Depots(); for (int i = 0; i < depots.CountItems(); i++) { const DepotInfo& depot = depots.ItemAtFast(i); BMessage* message = new BMessage(MSG_DEPOT_SELECTED); message->AddString("name", depot.Name()); BMenuItem* item = new BMenuItem(depot.Name(), message); repositoryMenu->AddItem(item); } BMenu* showMenu = fShowField->Menu(); showMenu->RemoveItems(0, showMenu->CountItems(), true); showMenu->AddItem(new BMenuItem(B_TRANSLATE("All categories"), new BMessage(MSG_CATEGORY_SELECTED))); showMenu->AddItem(new BSeparatorItem()); add_categories_to_menu(model.Categories(), showMenu); showMenu->ItemAt(0)->SetMarked(true); AdoptCheckmarks(model); }
void AttributeWindow::_CheckDisplayAs() { // check display as suported types type_code currentType = _CurrentType(); BMenu* menu = fDisplayAsMenuField->Menu(); for (int32 i = menu->CountItems(); i-- > 0;) { BMenuItem* item = menu->ItemAt(i); bool supported = item == _DefaultDisplayAs(); // the default type is always supported type_code type; for (int32 j = 0; item->Message()->FindInt32("supports", j, (int32*)&type) == B_OK; j++) { if (type == currentType) { supported = true; break; } } item->SetEnabled(supported); if (item->IsMarked() && !supported) menu->ItemAt(0)->SetMarked(true); } fSpecialControl->SetEnabled(!_DefaultDisplayAs()->IsMarked()); }
Window::Window() : BWindow(BRect(100, 100, 620, 200), "Alert-Test", B_TITLED_WINDOW, B_ASYNCHRONOUS_CONTROLS | B_AUTO_UPDATE_SIZE_LIMITS) { BMenu* sizeMenu = new BMenu("Button size"); sizeMenu->SetLabelFromMarked(true); sizeMenu->SetRadioMode(true); sizeMenu->AddItem(new BMenuItem("As usual", NULL)); sizeMenu->AddItem(new BMenuItem("From widest", NULL)); sizeMenu->AddItem(new BMenuItem("From label", NULL)); sizeMenu->ItemAt(0)->SetMarked(true); fSizeField = new BMenuField("Button size", sizeMenu); BMenu* typeMenu = new BMenu("Alert type"); typeMenu->SetLabelFromMarked(true); typeMenu->SetRadioMode(true); typeMenu->AddItem(new BMenuItem("Empty", NULL)); typeMenu->AddItem(new BMenuItem("Info", NULL)); typeMenu->AddItem(new BMenuItem("Idea", NULL)); typeMenu->AddItem(new BMenuItem("Warning", NULL)); typeMenu->AddItem(new BMenuItem("Stop", NULL)); typeMenu->ItemAt(0)->SetMarked(true); fTypeField = new BMenuField("Alert type", typeMenu); BMenu* spacingMenu = new BMenu("Button spacing"); spacingMenu->SetLabelFromMarked(true); spacingMenu->SetRadioMode(true); spacingMenu->AddItem(new BMenuItem("Even", NULL)); spacingMenu->AddItem(new BMenuItem("Offset", NULL)); spacingMenu->ItemAt(0)->SetMarked(true); fSpacingField = new BMenuField("Button spacing", spacingMenu); fCountSlider = new BSlider("count", "Button count", NULL, 1, 3, B_HORIZONTAL); fCountSlider->SetValue(3); fCountSlider->SetLimitLabels("1", "3"); fCountSlider->SetHashMarkCount(3); fCountSlider->SetHashMarks(B_HASH_MARKS_BOTTOM); fLastStringView = new BStringView("last pressed", ""); fLastStringView->SetAlignment(B_ALIGN_CENTER); BButton* button = new BButton("Show alert", new BMessage(kMsgShowAlert)); BLayoutBuilder::Group<>(this, B_VERTICAL) .Add(fSizeField) .Add(fTypeField) .Add(fSpacingField) .Add(fCountSlider) .AddGlue() .Add(fLastStringView) .Add(button) .SetInsets(B_USE_DEFAULT_SPACING); CenterOnScreen(); SetFlags(Flags() | B_CLOSE_ON_ESCAPE); }
void FilterView::AdoptModel(const Model& model) { // Adopt depots BMenu* repositoryMenu = fRepositoryField->Menu(); repositoryMenu->RemoveItems(0, repositoryMenu->CountItems(), true); repositoryMenu->AddItem(new BMenuItem(B_TRANSLATE("All depots"), new BMessage(MSG_DEPOT_SELECTED))); repositoryMenu->AddItem(new BSeparatorItem()); bool foundSelectedDepot = false; const DepotList& depots = model.Depots(); for (int i = 0; i < depots.CountItems(); i++) { const DepotInfo& depot = depots.ItemAtFast(i); BMessage* message = new BMessage(MSG_DEPOT_SELECTED); message->AddString("name", depot.Name()); BMenuItem* item = new BMenuItem(depot.Name(), message); repositoryMenu->AddItem(item); if (depot.Name() == model.Depot()) { item->SetMarked(true); foundSelectedDepot = true; } } if (!foundSelectedDepot) repositoryMenu->ItemAt(0)->SetMarked(true); // Adopt categories BMenu* showMenu = fShowField->Menu(); showMenu->RemoveItems(0, showMenu->CountItems(), true); showMenu->AddItem(new BMenuItem(B_TRANSLATE("All categories"), new BMessage(MSG_CATEGORY_SELECTED))); showMenu->AddItem(new BSeparatorItem()); add_categories_to_menu(model.Categories(), showMenu); bool foundSelectedCategory = false; for (int32 i = 0; i < showMenu->CountItems(); i++) { BMenuItem* item = showMenu->ItemAt(i); BMessage* message = item->Message(); if (message == NULL) continue; BString category; if (message->FindString("name", &category) == B_OK && model.Category() == category) { item->SetMarked(true); foundSelectedCategory = true; break; } } if (!foundSelectedCategory) showMenu->ItemAt(0)->SetMarked(true); }
/*********************************************************** * InitGUI ***********************************************************/ void HCriteriaView::InitGUI() { BRect rect = Bounds(); rect.left += 5; rect.top += 2; rect.right = rect.left + 80; BMenu *menu = new BMenu("menu"); menu->AddItem(new BMenuItem(_("Subject"),NULL)); menu->AddItem(new BMenuItem(_("To"),NULL)); menu->AddItem(new BMenuItem(_("From"),NULL)); menu->AddItem(new BMenuItem(_("Cc"),NULL)); menu->AddItem(new BMenuItem(_("Reply-To"),NULL)); menu->AddItem(new BMenuItem(_("Account"),NULL)); menu->ItemAt(0)->SetMarked(true); menu->SetRadioMode(true); menu->SetLabelFromMarked(true); fAttrMenu = new BMenuField(rect,"attr","",menu); fAttrMenu->SetDivider(0); AddChild(fAttrMenu); rect.OffsetBy(80,0); menu = new BMenu("menu"); menu->AddItem(new BMenuItem(_("contains"),NULL)); menu->AddItem(new BMenuItem(_("is"),NULL)); menu->AddItem(new BMenuItem(_("begin with"),NULL)); menu->AddItem(new BMenuItem(_("end with"),NULL)); menu->ItemAt(0)->SetMarked(true); menu->SetRadioMode(true); menu->SetLabelFromMarked(true); fOpMenu = new BMenuField(rect,"op","",menu); fOpMenu->SetDivider(0); AddChild(fOpMenu); rect.OffsetBy(80,2); rect.right= Bounds().right - 70; fValue = new BTextControl(rect,"value","","",NULL); fValue->SetDivider(0); AddChild(fValue); rect.right = Bounds().right - 5; rect.left = Bounds().right - 65; menu = new BMenu("operator"); menu->AddItem(new BMenuItem(_("and"),NULL)); menu->AddItem(new BMenuItem(_("or"),NULL)); menu->ItemAt(0)->SetMarked(true); menu->SetRadioMode(true); menu->SetLabelFromMarked(true); fOp2Menu= new BMenuField(rect,"op2","",menu); fOp2Menu->SetDivider(0); AddChild(fOp2Menu); }
/*********************************************************** * SetEnableControls ***********************************************************/ void HCriteriaView::SetEnableControls(bool enable) { fAttrMenu->SetEnabled(enable); BMenu *menu = fAttrMenu->Menu(); if(menu) menu->ItemAt(0)->SetMarked(true); fOpMenu->SetEnabled(enable); menu = fOpMenu->Menu(); if(menu) menu->ItemAt(0)->SetMarked(true); fValue->SetEnabled(enable); fValue->SetText(""); }
void MediaConverterWindow::BuildFormatMenu() { BMenu* menu = fFormatMenu->Menu(); BMenuItem* item; // clear out old format menu items while ((item = menu->RemoveItem((int32)0)) != NULL) delete item; // add menu items for each file format media_file_format mfi; int32 cookie = 0; FileFormatMenuItem* ff_item; while (get_next_file_format(&cookie, &mfi) == B_OK) { if ((mfi.capabilities & media_file_format::B_WRITABLE) == 0) continue; ff_item = new FileFormatMenuItem(&mfi); menu->AddItem(ff_item); } // mark first item item = menu->ItemAt(0); if (item != NULL) { item->SetMarked(true); ((BInvoker*)item)->Invoke(); } }
/*! \brief Set the control's value. \param value The new value of the control. Selects the option which has the given value. */ void BOptionPopUp::SetValue(int32 value) { BControl::SetValue(value); BMenu *menu = fMenuField->Menu(); if (menu == NULL) return; int32 numItems = menu->CountItems(); for (int32 i = 0; i < numItems; i++) { BMenuItem *item = menu->ItemAt(i); if (item && item->Message()) { int32 itemValue; item->Message()->FindInt32("be:value", &itemValue); if (itemValue == value) { item->SetMarked(true); #if BEHAVE_LIKE_R5 item->SetMarked(false); #endif break; } } } }
S9xRefreshWindow::S9xRefreshWindow(BRect rect, BWindow *parent, uint32 closemsg) : BWindow(rect, "FullScreen - Refresh Rate", B_FLOATING_WINDOW, B_NOT_ZOOMABLE | B_NOT_RESIZABLE), fWindow(parent), fS9xMsg(closemsg) { display_mode *modes; uint32 mode_count; if(BScreen().GetModeList(&modes, &mode_count) == B_NO_ERROR) { BMenu *menu = new BMenu("menu"); for(unsigned int i = 0; i < mode_count; i++) { // if((modes[i].virtual_width == 640) && (modes[i].space == B_RGB16)) { BMessage *msg = new BMessage(ID_REFRESH); msg->AddPointer("refr_rate", (void *)&modes[i]); BString item_name; item_name << (modes[i].timing.pixel_clock * 1000) / (modes[i].timing.h_total * modes[i].timing.v_total) << " Hz"; menu->AddItem(new BMenuItem(item_name.String(), msg)); // } } BRect r(20, 20, 200, 60); BMenuField *field = new BMenuField(r, "field", "Refresh Rate:", menu); AddChild(field); menu->SetLabelFromMarked(true); menu->ItemAt(0)->SetMarked(true); menu->SetTargetForItems(fWindow); } Show(); }
Tearoff::Tearoff(BRect frame, const char *name, MainWindow *parent, MenuName menu_name, int idx) : BWindow(frame, name, B_FLOATING_WINDOW, B_NOT_RESIZABLE | B_NOT_ZOOMABLE, 0) { int y = 0; BFont font; BMenu *menu; this->parent = parent; menu = parent->GetMenu(menu_name); menu->GetFont(&font); for(int i = 1; i < menu->CountItems(); i++) { BMenuItem *item = menu->ItemAt(i); if(item->Message()) { BButton *b = new BButton(BRect(0, y, frame.IntegerWidth(), y + TEAROFF_BUTTON_HEIGHT), "", item->Label(), new BMessage(item->Message()->what), B_FOLLOW_LEFT | B_FOLLOW_TOP, B_WILL_DRAW); font.SetSize(TEAROFF_FONT_SIZE); b->SetFont(&font); AddChild(b); y = y + TEAROFF_BUTTON_HEIGHT; } } this->ResizeTo(frame.IntegerWidth(), y); this->SetTitle(menu->Name()); this->index = idx; delete menu; }
BMenuItem* BootPromptWindow::_KeymapItemForLanguage(BLanguage& language) const { BLanguage english("en"); BString name; if (language.GetName(name, &english) != B_OK) return fDefaultKeymapItem; // Check special mappings first for (size_t i = 0; i < kLanguageKeymapMappingsSize; i += 2) { if (!strcmp(name, kLanguageKeymapMappings[i])) { name = kLanguageKeymapMappings[i + 1]; break; } } BMenu* menu = fKeymapsMenuField->Menu(); for (int32 i = 0; i < menu->CountItems(); i++) { BMenuItem* item = menu->ItemAt(i); BMessage* message = item->Message(); entry_ref ref; if (message->FindRef("ref", &ref) == B_OK && name == ref.name) return item; } return fDefaultKeymapItem; }
void AmProgramChangeView::SetEvent(AmPhraseEvent* container, AmProgramChange* pc) { ArpASSERT(container && pc); mContainer = container; bool updateAll = false; if (mProgramChange != pc) updateAll = true; mProgramChange = pc; if (updateAll || mCachedBankNumber != int32(BankNumber()) ) SetTrackRef(mTrackRef); if (updateAll || mCachedProgramNumber != int32(mProgramChange->ProgramNumber()) ) { BMenu* m = Menu(); if (m) { int32 count = m->CountItems(); for( int32 k = 0; k < count; k++ ) { BMenuItem* item = m->ItemAt( k ); if (item) { if( pc && k == pc->ProgramNumber() ) item->SetMarked( true ); else item->SetMarked(false); } } } } mCachedProgramNumber = mProgramChange->ProgramNumber(); mCachedBankNumber = BankNumber(); }
void TeamListView::UpdatePopUpPriorityMenu() { BMenuField *Priority = (BMenuField *)slayer->mainWindow->FindView("MainPriorityField"); BMenu *menu = Priority->Menu(); BMenuItem *item; int32 i; for (i = 2; (item = menu->ItemAt(i)); i++) { priorityMenu->ItemAt(i-2)->SetMarked(item->IsMarked()); priorityMenu->ItemAt(i-2)->SetEnabled(item->IsEnabled()); } }
/*! \brief Removes the option at the given index. \param index The index of the option to remove. */ void BOptionPopUp::RemoveOptionAt(int32 index) { BMenu *menu = fMenuField->Menu(); if (menu != NULL) { BMenuItem *item = menu->ItemAt(index); if (item != NULL) { menu->RemoveItem(item); delete item; } } }
BString AmControlChangeInfoView::MenuStringForControl(uint32 control) const { if (control > 127) return BString("?"); BMenu* menu = ControlMenu(); if (!menu) return BString( am_control_name(control) ); BMenuItem* item; for (int32 index = 0; (item = menu->ItemAt( index )); index++) { if (index == (int32)control) return BString( item->Label() ); } return BString( am_control_name(control) ); }
void InspectorWindow::TextModeChanged(int32 newMode) { AutoLocker<BLooper> lock(this); if (lock.IsLocked()) { BMenu* menu = fTextMode->Menu(); if (newMode < 0 || newMode > menu->CountItems()) return; BMenuItem* item = menu->ItemAt(newMode); item->SetMarked(true); } }
void ArpFontControl::SetFont(const ArpFont& font) { if (!mFontCtrl || !mSizeCtrl) return; mSizeCtrl->SetValue(int32(font.Size())); BMenu* m = mFontCtrl->Menu(); if (!m) return; BString16 family = font.Family(); BMenuItem* item; for (int32 k = 0; (item = m->ItemAt(k)) != 0; k++) { if (family == item->Label()) { item->SetMarked(true); } } }
void IconMenuItem::SetMarked(bool mark) { _inherited::SetMarked(mark); if (!mark) return; // we are marking the item BMenu* menu = Menu(); if (menu == NULL) return; // we have a parent menu BMenu* _menu = menu; while ((_menu = _menu->Supermenu()) != NULL) menu = _menu; // went up the hierarchy to found the topmost menu if (menu == NULL || menu->Parent() == NULL) return; // our topmost menu has a parent if (dynamic_cast<BMenuField*>(menu->Parent()) == NULL) return; // our topmost menu's parent is a BMenuField BMenuItem* topLevelItem = menu->ItemAt((int32)0); if (topLevelItem == NULL) return; // our topmost menu has a menu item IconMenuItem* topLevelIconMenuItem = dynamic_cast<IconMenuItem*>(topLevelItem); if (topLevelIconMenuItem == NULL) return; // our topmost menu's item is an IconMenuItem // update the icon topLevelIconMenuItem->SetIcon(fDeviceIcon); menu->Invalidate(); }
SketchApp::SketchApp() : BApplication("application/x-vnd.Prok-Sketch") { // most of this function was ripped out of Be's old HelloWorld Example SketchWindow *mainWindow = NULL; SketchView *aView = NULL; BMenuBar *myMenubar = NULL; BMenu *firstMenu = NULL, *secondMenu = NULL; BRect aRect; menu_info m_info; int32 menubarheight=0; // the price we pay to be font sensitive... get_menu_info(&m_info); menubarheight = (int32)m_info.font_size + 8; aRect.Set(100, 100, 449, 349 + menubarheight); mainWindow = new SketchWindow(aRect); // a pretty standard set of menus aRect.Set(0,0, mainWindow->Bounds().Width(), menubarheight); myMenubar = new BMenuBar(aRect, "menubar"); // main menu firstMenu = new BMenu("Sketch"); firstMenu->AddItem(new BMenuItem("About Sketch", new BMessage(B_ABOUT_REQUESTED), 'A', B_COMMAND_KEY)); firstMenu->AddItem(new BMenuItem("Save", new BMessage(SAVE_BITMAP), 'S', B_COMMAND_KEY)); firstMenu->AddItem(new BMenuItem("Quit", new BMessage(B_QUIT_REQUESTED), 'Q', B_COMMAND_KEY)); ((BMenuItem *)firstMenu->ItemAt(0))->SetTarget(be_app); ((BMenuItem *)firstMenu->ItemAt(1))->SetTarget(be_app); #if __INTEL__ // only cuz the translation kit is busted in R3, will undo in R3.1 //((BMenuItem *)firstMenu->ItemAt(1))->SetEnabled(false); #endif // edit menu secondMenu = new BMenu("Edit"); secondMenu->AddItem(new BMenuItem("Erase", new BMessage(ANIMATED_ERASE), 'E', B_COMMAND_KEY)); myMenubar->AddItem(firstMenu); myMenubar->AddItem(secondMenu); // SketchView aRect.Set(0,menubarheight -1, mainWindow->Bounds().Width(), mainWindow->Bounds().Height()); aView = new SketchView(aRect, "SketchView"); // add views to window mainWindow->AddChild(aView); mainWindow->AddChild(myMenubar); // make window visible mainWindow->Show(); }
void T9InputServerMethod::SetMode(T9Mode mode) { BAutolock l(fLocker); BMenuItem *item; // XXX: check fMode = mode; item = fDeskbarMenu->FindMarked(); if (item) item->SetMarked(false); item = fDeskbarMenu->ItemAt((int32)mode); if (item) item->SetMarked(true); // necessary to update the copy used by the Deskbar icon. SetMenu(fDeskbarMenu, BMessenger(this)); }
void AmControlChangeInfoView::SetConfiguration(const BMessage* config) { int32 tmp; if (config->FindInt32(STR_CONTROL_CHANGE, &tmp) == B_OK) { mCc = (uchar)tmp; BMenu* menu = ControlMenu(); if (menu) { BMenuItem* item; for (int32 index = 0; (item = menu->ItemAt( index )); index++) { if (index == mCc) item->SetMarked(false); else item->SetMarked(true); } } } }
void Renamer_Remove::AttachedToWindow() { BMessage msg; ReadPreferences("ren_remove", msg); BString string = ""; int32 integer = 0; bool boolean = 0; if (msg.FindInt32("pos1", &integer) == B_OK) fPosition1->SetValue(integer); if (msg.FindInt32("pos2", &integer) == B_OK) fPosition2->SetValue(integer); if (msg.FindBool("direction1", &boolean) == B_OK) { BMenu* menu = fDirection1->Menu(); for (int i = 0; i < 2; ++i) menu->ItemAt(i)->SetMarked(i == (int)boolean); } if (msg.FindBool("direction2", &boolean) == B_OK) { BMenu* menu = fDirection2->Menu(); for (int i = 0; i < 2; ++i) menu->ItemAt(i)->SetMarked(i == (int)boolean); } }
void AccountView::AttachedToWindow() { // Once we are attached to window, the GUI is already created // so we can set our window as target for messages for (int32 i = 0; i < CountChildren(); i++) { BView* child = ChildAt(i); BMenu* menu = dynamic_cast<BMenu*>(child); BMenuField* menuField = dynamic_cast<BMenuField*>(child); BTextControl* textControl = dynamic_cast<BTextControl*>(child); NotifyingTextView* textView = dynamic_cast<NotifyingTextView*>(child); BCheckBox* checkBox = dynamic_cast<BCheckBox*>(child); if (menuField) menu = menuField->Menu(); if (menu) { for (int32 j = 0; j < menu->CountItems(); j++) { BMenuItem* item = menu->ItemAt(j); item->SetMessage(new BMessage(kChanged)); item->SetTarget(Window()); } menu->SetTargetForItems(Window()); } if (textControl) { textControl->SetMessage(new BMessage(kChanged)); textControl->SetTarget(Window()); } if (checkBox) { checkBox->SetMessage(new BMessage(kChanged)); checkBox->SetTarget(Window()); } if (textView) { textView->SetMessage(new BMessage(kChanged)); textView->SetTarget(Window()); } } }
void InspectorWindow::_LoadMenuFieldMode(BMenuField* field, const char* name, const BMessage& settings) { BString fieldName; int32 mode; fieldName.SetToFormat("%sMode", name); if (settings.FindInt32(fieldName.String(), &mode) == B_OK) { BMenu* menu = field->Menu(); for (int32 i = 0; i < menu->CountItems(); i++) { BInvoker* item = menu->ItemAt(i); if (item->Message()->FindInt32("mode") == mode) { item->Invoke(); break; } } } }
void ArpMenuField::ComputeDimens(ArpDimens& cur_dimens) { BMenu* menu = MenuBar(); BMenu* popup = Menu(); if( menu ) { copy_attrs(menu); copy_attrs(popup); menu->SetFont(&PV_MenuFont); menu->InvalidateLayout(); } get_view_dimens(&cur_dimens, this, false); font_height fhs; BasicFont()->GetHeight(&fhs); const float fh = fhs.ascent+fhs.descent+fhs.leading; float fw = BasicFont()->StringWidth("WWWW"); float pref_w=0; if( popup ) { int32 num = popup->CountItems(); for( int32 i=0; i<num; i++ ) { BMenuItem* item = popup->ItemAt(i); if( item ) { const float w=BasicFont()->StringWidth(item->Label()); ArpD(cdb << ADH << "Dimensions for popup label " << item->Label() << ": " << w << endl); if( w > pref_w ) pref_w = w; } } } cur_dimens.Y().SetTo(0, fh+12, fh+12, fh+12, 0); float labelWidth = (Label() && *Label()) ? BasicFont()->StringWidth(Label()) + BasicFont()->StringWidth(" ") : 0; cur_dimens.X().SetTo(labelWidth, (fw < pref_w ? fw : pref_w) + 20, pref_w + 20, pref_w + 20, 0); }
void InspectorWindow::_LoadMenuFieldMode(BMenuField* field, const char* name, const GUITeamUISettings* settings) { BVariant value; BString fieldName; fieldName.SetToFormat("inspectorWindow%sMode", name); status_t error = settings->Value(fieldName.String(), value); if (error == B_OK) { BMenu* menu = field->Menu(); for (int32 i = 0; i < menu->CountItems(); i++) { BInvoker* item = menu->ItemAt(i); if (item->Message()->FindInt32("mode") == value.ToInt32()) { item->Invoke(); break; } } } }
void TeamListView::ItemsToPopUpPriorityMenu() { BMenuField *Priority = (BMenuField *)slayer->mainWindow->FindView("MainPriorityField"); BMenu *menu = Priority->Menu(); BMenuItem *add; int32 i; for (i = 2; (add = menu->ItemAt(i)); i++) { BMenuItem *newItem; if (add->Label() && add->Label()[0]) newItem = new BMenuItem(add->Label(), new BMessage( add->Command())); else newItem = new BSeparatorItem(); newItem->SetTarget(slayer->mainWindow); priorityMenu->AddItem(newItem); } // priorityMenu->AddItem(add); }
/*********************************************************** * MessageReceived ***********************************************************/ void HAddressView::MessageReceived(BMessage *message) { switch(message->what) { case M_ACCOUNT_CHANGE: { const char* name; if(message->FindString("name",&name) != B_OK) break; ChangeAccount(name); PRINT(("Name:%s\n",name)); break; } case M_SEL_GROUP: { BMenu *menu; BTextControl *control; if(message->FindPointer("menu",(void**)&menu) != B_OK || message->FindPointer("control",(void**)&control) != B_OK) break; if(control) { BString text = control->Text(); if(text.Length() != 0) text += ","; int32 count = menu->CountItems(); for(int32 i = 0;i < count;i++) { const char* label = menu->ItemAt(i)->Label(); text += label; if(i != count-1) text += ","; } control->SetText(text.String() ); } break; } default: BView::MessageReceived(message); } }