/*! \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; } } } }
//-------------------------------------------------------------------- void InterView::MouseDown(BPoint point) { BMenuItem *selected; BPoint cursor; uint32 buttons; GetMouse(&cursor, &buttons, false); if (buttons & B_PRIMARY_MOUSE_BUTTON) { mouseDown = true; mouseCoord = point; SetMouseEventMask(B_POINTER_EVENTS,B_LOCK_WINDOW_FOCUS); // be_app->SetCursor(B_I_BEAM_CURSOR); } if (buttons & B_SECONDARY_MOUSE_BUTTON) { ConvertToScreen(&point); selected = menu->Go(point); if ( selected && (selected->Message() != NULL)) if (selected->Message()->what == MSG_ZOOM_IN) ZoomIn(); else if (selected->Message()->what == MSG_ZOOM_OUT) ZoomOut(); else msgDest->PostMessage(selected->Message()); } if (buttons & B_TERTIARY_MOUSE_BUTTON) { ((InterApp*)be_app)->theWin->SwapFullScreenNoMenu(); } }
void ScreenshotWindow::_SetupTranslatorMenu() { BMessage message(kImageFormat); fTranslatorMenu = new BMenu("Please select"); BTranslationUtils::AddTranslationItems(fTranslatorMenu, B_TRANSLATOR_BITMAP, &message, NULL, NULL, NULL); fTranslatorMenu->SetLabelFromMarked(true); if (fTranslatorMenu->ItemAt(0)) fTranslatorMenu->ItemAt(0)->SetMarked(true); int32 imageFileType; for (int32 i = 0; i < fTranslatorMenu->CountItems(); ++i) { BMenuItem* item = fTranslatorMenu->ItemAt(i); if (item != NULL && item->Message()) { item->Message()->FindInt32("be:type", &imageFileType); if (fImageFileType == imageFileType) { item->SetMarked(true); MessageReceived(item->Message()); break; } } } }
void CalcView::MouseDown(BPoint point) { // ensure this view is the current focus if (!fExpressionTextView->IsFocus()) { // Call our version of MakeFocus(), since that will also apply the // num_lock setting. MakeFocus(); } // read mouse buttons state int32 buttons = 0; Window()->CurrentMessage()->FindInt32("buttons", &buttons); if ((B_PRIMARY_MOUSE_BUTTON & buttons) == 0) { // display popup menu if not primary mouse button BMenuItem* selected; if ((selected = fPopUpMenu->Go(ConvertToScreen(point))) != NULL && selected->Message() != NULL) { Window()->PostMessage(selected->Message(), this); } return; } if (fOptions->keypad_mode == KEYPAD_MODE_COMPACT) { if (fCalcIcon != NULL) { BRect bounds(Bounds()); bounds.left = bounds.right - fCalcIcon->Bounds().Width(); if (bounds.Contains(point)) { // user clicked on calculator icon fExpressionTextView->Clear(); } } return; } // calculate grid sizes float sizeDisp = fHeight * kDisplayScaleY; float sizeCol = fWidth / (float)fColumns; float sizeRow = (fHeight - sizeDisp) / (float)fRows; // calculate location within grid int gridCol = (int)floorf(point.x / sizeCol); int gridRow = (int)floorf((point.y - sizeDisp) / sizeRow); // check limits if ((gridCol >= 0) && (gridCol < fColumns) && (gridRow >= 0) && (gridRow < fRows)) { // process key press int key = gridRow * fColumns + gridCol; _FlashKey(key, FLAGS_MOUSE_DOWN); _PressKey(key); // make sure we receive the mouse up! SetMouseEventMask(B_POINTER_EVENTS, B_LOCK_WINDOW_FOCUS); } }
//------------------------------------------------------------------------------ void MenuEditor::OnSelectionChanged(BMessage* /*msg*/) { if ((fListView->CurrentSelection() < 0) || is_kind_of(CurrentItem(), BSeparatorItem)) { fLabelText->SetText(""); fLabelText->SetEnabled(false); fMsgText->SetText("none"); fMsgText->SetEnabled(false); fShortcutText->SetText(""); fShortcutText->SetEnabled(false); fModifierField->Menu()->ItemAt(0)->SetMarked(false); fModifierField->Menu()->ItemAt(1)->SetMarked(false); fModifierField->Menu()->ItemAt(2)->SetMarked(false); fModifierField->SetEnabled(false); fEnabledBox->SetEnabled(false); fEnabledBox->SetValue(B_CONTROL_OFF); return; } else { fLabelText->SetEnabled(true); fMsgText->SetEnabled(true); fModifierField->Menu()->ItemAt(0)->SetMarked(false); fModifierField->Menu()->ItemAt(1)->SetMarked(false); fModifierField->Menu()->ItemAt(2)->SetMarked(false); fEnabledBox->SetEnabled(true); fEnabledBox->SetValue(CurrentItem()->IsEnabled()); fShortcutText->SetEnabled(CurrentItem()->Submenu() == NULL); } fLabelText->SetText(CurrentItem()->Label()); char temp[5]; BMenuItem *item = CurrentItem(); if (item->Message() != NULL) strncpy(temp, (char *)(new int32(flipcode(item->Message()->what))), 4); else strcpy(temp, "none"); temp[4] = 0; fMsgText->SetText(temp); uint32 mod; temp[1] = 0; temp[0] = item->Shortcut(&mod); fShortcutText->SetText(temp); fModifierField->SetEnabled(*temp); if (*temp) { fModifierField->Menu()->ItemAt(0)->SetMarked(mod & B_OPTION_KEY); fModifierField->Menu()->ItemAt(1)->SetMarked(mod & B_SHIFT_KEY); fModifierField->Menu()->ItemAt(2)->SetMarked(mod & B_CONTROL_KEY); } }
static void populate_colors(BMenu* dest, const BMessage& src, const BMessage& names, const BMessage* initial) { type_code type; int32 n; ssize_t size; rgb_color *col; const char *name; src.GetInfo ("color", &type, &n); for (int32 j = 0; j < n; j++) { names.FindString ("color", j, &name); if (src.FindData ("color", B_RGB_COLOR_TYPE, j, (const void **)(&col), &size) == B_OK) { // See if this field already exists in the menu. const int32 k = dest->CountItems(); int32 i; bool found = false; for (i=0; i<k; i++) { BMenuItem* it = dest->ItemAt(i); const char* field; if (it && it->Message() && it->Message()->FindString("field", &field) == B_OK && strcmp(field, name) == 0) { ColorMenuItem* ci = dynamic_cast<ColorMenuItem*>(it); if (ci) ci->SetColor(*col); found = true; break; } } if (found) continue; // This color doesn't currently exist; add it in. BMessage* msg = new BMessage(CMD_CHOOSE_UI_COLOR); msg->AddString("field", name); msg->AddInt32("index", j); const char* label = name; // Alphabetical order. for (i=0; i<n; i++) { BMenuItem* it = dest->ItemAt(i); if (it && strcmp(it->Label(), label) > 0) break; } rgb_color *init_col; if (!initial || initial->FindData ("color", B_RGB_COLOR_TYPE, j, (const void **)&init_col, &size) != B_OK) *init_col = *col; ColorMenuItem* ci = new ColorMenuItem(label, msg, *col, *init_col); dest->AddItem(ci); } } }
void TDeskbarMenu::ResetTargets() { // This method does not recurse into submenus // and does not affect menu items in submenus. // (e.g. "Restart System" and "Power Off") BNavMenu::ResetTargets(); // if we are dragging, set the target to whatever was set // else set it to the default (Tracker) if (!fBarView->Dragging()) SetTarget(DefaultTarget()); // now set the target for the menuitems to the currently // set target, which may or may not be tracker SetTargetForItems(Target()); for (int32 i = 0; ; i++) { BMenuItem* item = ItemAt(i); if (item == NULL) break; if (item->Message()) { switch (item->Message()->what) { case kFindButton: item->SetTarget(BMessenger(kTrackerSignature)); break; case kShowSplash: case kToggleDraggers: case kConfigShow: case kConfigQuit: case kAlwaysTop: case kExpandNewTeams: case kHideLabels: case kResizeTeamIcons: case kSortRunningApps: case kTrackerFirst: case kRebootSystem: case kSuspendSystem: case kShutdownSystem: case kShowHideTime: case kShowSeconds: case kShowDayOfWeek: case kShowTimeZone: case kGetClockSettings: item->SetTarget(be_app); break; } } } }
bool _AmControlMenu::IsBuilt() const { int32 count = CountItems(); if (count > 1) return true; if (count == 1) { BMenuItem* item = ItemAt(0); if (!item) return false; if (!item->Message()) return false; if (item->Message()->what == 'null') return false; return true; } return false; }
type_code AttributeWindow::_CurrentType() const { type_code type = B_STRING_TYPE; BMenuItem* item = fTypeMenu->FindMarked(); if (item != NULL && item->Message() != NULL) { int32 value; if (item->Message()->FindInt32("type", &value) == B_OK) type = value; } return type; }
status_t InspectorWindow::_SaveMenuFieldMode(BMenuField* field, const char* name, BMessage& settings) { BMenuItem* item = field->Menu()->FindMarked(); if (item && item->Message()) { int32 mode = item->Message()->FindInt32("mode"); BString fieldName; fieldName.SetToFormat("%sMode", name); return settings.AddInt32(fieldName.String(), mode); } return B_OK; }
/** * @brief Shows context menu. This utility function is called by derived classes. * @param[in] popupMenu menu. * @param[in] menuPos position of menu (in screen coordinates) */ void BeSkinView::showContextMenu(BPopUpMenu* popupMenu, Point32 menuPos) { BWindow* window = Window(); BAutolock locker(window); // Show popup menu. BPoint point(menuPos.x, menuPos.y); BRect rect(point, point); rect.InsetBy(-5, -5); BMenuItem* selectedMenuItem = popupMenu->Go(point, false, true, rect, false); if (NULL != selectedMenuItem && NULL != selectedMenuItem->Message()) { BMessenger messenger(this); messenger.SendMessage(selectedMenuItem->Message()); } }
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; }
void ScreenshotWindow::_AddItemToPathMenu(const char* path, BString& label, int32 index, bool markItem, uint32 shortcutKey) { // Make sure that item won't be a duplicate of an existing one for (int32 i = fOutputPathMenu->CountItems() - 1; i >= 0; --i) { BMenuItem* menuItem = fOutputPathMenu->ItemAt(i); BMessage* message = menuItem->Message(); const char* pathFromItem; if (message != NULL && message->what == kLocationChanged && message->FindString("path", &pathFromItem) == B_OK && !strcmp(path, pathFromItem)) { if (markItem) { fOutputPathMenu->ItemAt(i)->SetMarked(true); fLastSelectedPath = fOutputPathMenu->ItemAt(i); } return; } } BMessage* message = new BMessage(kLocationChanged); message->AddString("path", path); fOutputPathMenu->TruncateString(&label, B_TRUNCATE_MIDDLE, fOutputPathMenu->StringWidth("SomethingLongHere")); fOutputPathMenu->AddItem(new BMenuItem(label.String(), message, shortcutKey), index); if (markItem) { fOutputPathMenu->ItemAt(index)->SetMarked(true); fLastSelectedPath = fOutputPathMenu->ItemAt(index); } }
bool AutoConfigView::GetBasicAccountInfo(account_info &info) { status_t status = B_OK; BString inboundProtocolName = ""; BMenuItem* item = fInProtocolsField->Menu()->FindMarked(); if (item) { inboundProtocolName = item->Label(); item->Message()->FindRef("protocol", &(info.inboundProtocol)); } else status = B_ERROR; if (inboundProtocolName.FindFirst("IMAP") >= 0) info.inboundType = IMAP; else info.inboundType = POP; info.outboundProtocol = fSMTPAddOnRef; info.name = fNameView->Text(); info.accountName = fAccountNameView->Text(); info.email = fEmailView->Text(); info.loginName = fLoginNameView->Text(); info.password = fPasswordView->Text(); return status; }
/*! Marks a keyboard layout item by iterating through the menus recursively searching for the menu item with the passed in path. This method always iterates through all menu items and unmarks them. If no item with the passed in path is found it is up to the caller to set the default keyboard layout and mark item corresponding to the default keyboard layout path. */ void KeymapWindow::_MarkKeyboardLayoutItem(const char* path, BMenu* menu) { BMenuItem* item = NULL; entry_ref ref; for (int32 i = 0; i < menu->CountItems(); i++) { item = menu->ItemAt(i); if (item == NULL) continue; // Unmark each item initially item->SetMarked(false); BMenu* submenu = item->Submenu(); if (submenu != NULL) _MarkKeyboardLayoutItem(path, submenu); else { if (item->Message()->FindRef("ref", &ref) == B_OK) { BPath layoutPath(&ref); if (path != NULL && path[0] != '\0' && layoutPath == path) { // Found it, mark the item item->SetMarked(true); } } } } }
/*! Gets the path of the currently marked keyboard layout item by searching through each of the menus recursively until a marked item is found. */ BPath KeymapWindow::_GetMarkedKeyboardLayoutPath(BMenu* menu) { BPath path; BMenuItem* item = NULL; entry_ref ref; for (int32 i = 0; i < menu->CountItems(); i++) { item = menu->ItemAt(i); if (item == NULL) continue; BMenu* submenu = item->Submenu(); if (submenu != NULL) return _GetMarkedKeyboardLayoutPath(submenu); else { if (item->IsMarked() && item->Message()->FindRef("ref", &ref) == B_OK) { path.SetTo(&ref); return path; } } } return path; }
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()); }
void BootPromptWindow::MessageReceived(BMessage* message) { switch (message->what) { case MSG_LANGUAGE_SELECTED: if (LanguageItem* item = static_cast<LanguageItem*>( fLanguagesListView->ItemAt( fLanguagesListView->CurrentSelection(0)))) { BMessage preferredLanguages; preferredLanguages.AddString("language", item->Language()); MutableLocaleRoster::Default()->SetPreferredLanguages( &preferredLanguages); _InitCatalog(true); // Select default keymap by language BLanguage language(item->Language()); BMenuItem* keymapItem = _KeymapItemForLanguage(language); if (keymapItem != NULL) { keymapItem->SetMarked(true); _ActivateKeymap(keymapItem->Message()); } } // Calling it here is a cheap way of preventing the user to have // no item selected. Always the current item will be selected. _UpdateStrings(); break; case MSG_KEYMAP_SELECTED: _ActivateKeymap(message); break; default: BWindow::MessageReceived(message); } }
/*! Activate appropriate menu item according to selected refresh rate */ void ScreenWindow::_UpdateRefreshControl() { for (int32 i = 0; i < fRefreshMenu->CountItems(); i++) { BMenuItem* item = fRefreshMenu->ItemAt(i); if (item->Message()->FindFloat("refresh") == fSelected.refresh) { item->SetMarked(true); // "Other" items only contains a refresh rate when active fOtherRefresh->SetLabel(B_TRANSLATE("Other" B_UTF8_ELLIPSIS)); return; } } // this is a non-standard refresh rate if (fOtherRefresh != NULL) { fOtherRefresh->Message()->ReplaceFloat("refresh", fSelected.refresh); fOtherRefresh->SetMarked(true); BString string; refresh_rate_to_string(fSelected.refresh, string); fRefreshMenu->Superitem()->SetLabel(string.String()); string.Append(B_TRANSLATE("/other" B_UTF8_ELLIPSIS)); fOtherRefresh->SetLabel(string.String()); } }
void PropEnumFlagEditor::HandleEdit(int32 value) { int32 newValue = 0; for (int32 i = 0; i < fMenu->CountItems(); i++) { BMenuItem *item = fMenu->ItemAt(i); int32 temp; if (!item || item->Message()->FindInt32("value",&temp) != B_OK) continue; if (temp == value) { if (item->IsMarked()) { item->SetMarked(false); continue; } else item->SetMarked(true); } if (item->IsMarked()) newValue |= temp; } PropEnumEditor::HandleEdit(newValue); }
int GSubMenu::Float(GView *Parent, int x, int y, bool Left) { if (Info) { BPopUpMenu *Popup = new BPopUpMenu("PopUpMenu"); if (Popup) { _CopyMenu(Popup, this); BPoint Pt(x, y); BMenuItem *Item = Popup->Go(Pt); if (Item) { #undef Message BMessage *Msg = Item->Message(); int32 i; if (Msg && Msg->FindInt32("Cmd", &i) == B_OK) { return i; } } } } return 0; }
status_t KeymapWindow::_SetKeyboardLayout(const char* path) { status_t status = B_OK; if (path != NULL && path[0] != '\0') { status = fKeyboardLayoutView->GetKeyboardLayout()->Load(path); if (status == B_OK) { // select item for (int32 i = fLayoutMenu->CountItems(); i-- > 0;) { BMenuItem* item = fLayoutMenu->ItemAt(i); BMessage* message = item->Message(); entry_ref ref; if (message->FindRef("ref", &ref) == B_OK) { BPath layoutPath(&ref); if (layoutPath == path) { item->SetMarked(true); break; } } } } } if (path == NULL || status != B_OK) { fKeyboardLayoutView->GetKeyboardLayout()->SetDefault(); fLayoutMenu->ItemAt(0)->SetMarked(true); } // Refresh currently set layout fKeyboardLayoutView->SetKeyboardLayout( fKeyboardLayoutView->GetKeyboardLayout()); return status; }
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 DraggableListView::MouseDown(BPoint point) { uint32 buttons = Looper()->CurrentMessage()->FindInt32("buttons"); int32 index = IndexOf(point); if (buttons & B_SECONDARY_MOUSE_BUTTON && index >= 0) { Select(index); if (list_type == filter) { BPopUpMenu popup_menu("popup_menu", false, false); popup_menu.SetFont(be_plain_font); BMessage* del_msg = new BMessage(SM_REMOVE_FILTER); del_msg->AddInt32("filter_id", ((FilterItem*)ItemAt(index))->FilterID()); BMessage* help_msg = new BMessage(SM_HELP_REQUESTED); help_msg->AddString("addon_name", ((FilterItem*)ItemAt(index))->Text()); popup_menu.AddItem(new BMenuItem("Delete", del_msg)); popup_menu.AddItem(new BMenuItem("Add-on Help"B_UTF8_ELLIPSIS, help_msg)); BMenuItem* item = popup_menu.Go(ConvertToScreen(point)); if (item != NULL) { if (strcmp(item->Label(),"Delete") == 0) { be_app_messenger.SendMessage(item->Message()); delete RemoveItem(index); if (strcmp(item->Label(),"Add-on Help"B_UTF8_ELLIPSIS) == 0) Window()->PostMessage(item->Message()); } } } else { BView* active_list = Window()->FindView("active_list"); if (active_list != NULL) { BPopUpMenu popup_menu("popup_menu", false, false); popup_menu.SetFont(be_plain_font); BMessage* add_msg = new BMessage(SM_DRAG_FILTER); add_msg->AddString("filter_name", ((BStringItem*)ItemAt(index))->Text()); BMessage* help_msg = new BMessage(SM_HELP_REQUESTED); help_msg->AddString("addon_name", ((BStringItem*)ItemAt(index))->Text()); popup_menu.AddItem(new BMenuItem("Add", add_msg)); popup_menu.AddItem(new BMenuItem("Add-on Help"B_UTF8_ELLIPSIS, help_msg)); BMenuItem* item = popup_menu.Go(ConvertToScreen(point)); if (item != NULL) { if (strcmp(item->Label(),"Add") == 0) active_list->MessageReceived(item->Message()); if (strcmp(item->Label(),"Add-on Help"B_UTF8_ELLIPSIS) == 0) Window()->PostMessage(item->Message()); } } } } BListView::MouseDown(point); }
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); }
void SeqPhrasePropertyWindow::GetColor() { if (!mSongRef.IsValid() || !mEvent || !mColorField || !mColorCtrl) return; BMenuItem* item = mColorField->Menu()->FindMarked(); if (!item || !item->Message() ) return; AmPhrase::ColorCode colorCode = code_for_what(item->Message()->what); // READ SONG BLOCK const AmSong* song = mSongRef.ReadLock(); if (song) { AmPhrase* phrase = mEvent->Phrase(); if (phrase) { mColorCtrl->SetValue( phrase->Color(colorCode) ); } } mSongRef.ReadUnlock(song); // END READ SONG BLOCK }
void SeqPhrasePropertyWindow::SetColor() { if (!mSongRef.IsValid() || !mEvent || !mColorField || !mColorCtrl) return; BMenuItem* item = mColorField->Menu()->FindMarked(); if (!item || !item->Message() ) return; AmPhrase::ColorCode colorCode = code_for_what(item->Message()->what); // WRITE SONG BLOCK AmSong* song = mSongRef.WriteLock(); if (song) { AmPhrase* phrase = mEvent->Phrase(); if (phrase) { phrase->SetColor(colorCode, mColorCtrl->ValueAsColor() ); } } mSongRef.WriteUnlock(song); // END WRITE SONG BLOCK }
status_t OutputView::GetCodecsForFamily(const media_format_family &family, const int32 &width, const int32 &height, BMenu *codecs, media_format &initialFormat) { SetInitialFormat(width, height, Settings().ClipDepth(), 10, initialFormat); // find the full media_file_format corresponding to // the given format family (e.g. AVI) media_file_format fileFormat; if (!GetMediaFileFormat(family, fileFormat)) return B_ERROR; BString currentCodec; BMenuItem *marked = codecs->FindMarked(); if (marked != NULL) currentCodec = marked->Label(); // suspend updates while we're rebuilding this menu in order to // reduce window flicker and other annoyances Window()->BeginViewTransaction(); codecs->RemoveItems(0, codecs->CountItems(), true); int32 cookie = 0; media_codec_info codec; media_format dummyFormat; while (get_next_encoder(&cookie, &fileFormat, &initialFormat, &dummyFormat, &codec) == B_OK) { BMenuItem *item = CreateCodecMenuItem(codec); if (item != NULL) codecs->AddItem(item); if (codec.pretty_name == currentCodec) item->SetMarked(true); } if (codecs->FindMarked() == NULL) { BMenuItem *item = codecs->ItemAt(0); if (item != NULL) item->SetMarked(true); } Window()->EndViewTransaction(); marked = codecs->FindMarked(); BMessage *message = marked->Message(); media_codec_info *info; ssize_t size; if (message->FindData(kCodecData, B_SIMPLE_DATA, (const void **)&info, &size) == B_OK) fController->SetMediaCodecInfo(*info); return B_OK; }
PaperCap * PageSetupView::GetPaperCap() { BMenuItem *item = fPaper->FindMarked(); void *pointer; if (item != NULL && item->Message()->FindPointer("paperCap", &pointer) == B_OK) { return (PaperCap*)pointer; } else { return (PaperCap*)fPrinterCap->GetDefaultCap(PrinterCap::kPaper); } }
JobData::Orientation PageSetupView::GetOrientation() { BMenuItem *item = fOrientation->FindMarked(); int32 orientation; if (item != NULL && item->Message()->FindInt32("orientation", &orientation) == B_OK) { return (JobData::Orientation)orientation; } else { return JobData::kPortrait; } }