void SeqStudioWindow::MenusBeginning() { inherited::MenusBeginning(); BMenuBar* bar = KeyMenuBar(); if (!bar) return; BColumnListView* table = dynamic_cast<BColumnListView*>( FindView(ENDPOINT_LIST_STR) ); if (!table) return; if (mDeviceCtrl && mDeviceCtrl->Menu() ) add_device_menu_items(mDeviceCtrl->Menu() ); // MIDI Port menu if (mPortMenu) { bool deleteEnabled = false; _EndpointRow* r = dynamic_cast<_EndpointRow*>(table->CurrentSelection() ); if (r && !r->mIsValid && r->mEndpoint.channel < 0) deleteEnabled = true; BMenuItem* deleteItem = mPortMenu->FindItem(DELETE_STR); if (deleteItem && deleteItem->IsEnabled() != deleteEnabled) deleteItem->SetEnabled(deleteEnabled); } // Attributes menu BMenu* menu; BMenuItem* item; if ( (menu = bar->SubmenuAt(ATTRIBUTES_MENU_INDEX)) != NULL) { for (int32 k = 0; (item = menu->ItemAt(k)) != NULL; k++) { const char* n; if (item->Message() && item->Message()->FindString(COLUMN_NAME_STR, &n) == B_OK) { BColumn* col = column_named(n, table); if (col && col->IsVisible() ) { if (!item->IsMarked() ) item->SetMarked(true); } else { if (item->IsMarked() ) item->SetMarked(false); } } } } }
void YabWindow::MessageReceived(BMessage *message) { // if(message) message->PrintToStream(); switch(message->what) { case YABBUTTON: { BString tmpMessage(""); BButton *myButtonPressed; message->FindPointer("source",(void **) &myButtonPressed); tmpMessage += myButtonPressed->Name(); tmpMessage += "|"; messageString += tmpMessage; } break; case YABMENU: { BString tmpMessage(""); BMenuItem *mySelectedMenu; message->FindPointer("source",(void **) &mySelectedMenu); BMenu *myMenu = mySelectedMenu->Menu(); tmpMessage += ((BMenuBar*)myMenu->Supermenu())->Parent()->Name(); tmpMessage += ":"; tmpMessage += myMenu->Name(); tmpMessage += ":"; tmpMessage += mySelectedMenu->Label(); tmpMessage += "|"; messageString += tmpMessage; } break; case YABSUBMENU: { BString tmpMessage(""); BMenuItem *mySelectedMenu; message->FindPointer("source",(void **) &mySelectedMenu); BMenu *myMenu = mySelectedMenu->Menu(); tmpMessage += ((BMenuBar*)myMenu->Supermenu()->Supermenu())->Parent()->Name(); tmpMessage += ":"; tmpMessage += myMenu->Supermenu()->Name(); tmpMessage += ":"; tmpMessage += myMenu->Name(); tmpMessage += ":"; tmpMessage += mySelectedMenu->Label(); tmpMessage += "|"; messageString += tmpMessage; } break; case YABTEXTCONTROL: { BString tmpMessage(""); BTextControl *myTextControl; message->FindPointer("source",(void **) &myTextControl); tmpMessage += myTextControl->Name(); tmpMessage += ":"; tmpMessage += myTextControl->Text(); tmpMessage += "|"; messageString += tmpMessage; } break; case YABCHECKBOX: { BString tmpMessage(""); BCheckBox *myCheckBox; message->FindPointer("source",(void **) &myCheckBox); tmpMessage += myCheckBox->Name(); tmpMessage += ":"; if(myCheckBox->Value()==B_CONTROL_ON) tmpMessage += "ON|"; else tmpMessage += "OFF|"; messageString += tmpMessage; } break; case YABRADIOBUTTON: { BString tmpMessage(""); BRadioButton *myRadioButton; message->FindPointer("source",(void **) &myRadioButton); tmpMessage += myRadioButton->Name(); tmpMessage += "|"; messageString += tmpMessage; } break; case YABLISTBOXINVOKE: { BListView *myList; message->FindPointer("source",(void **) &myList); int i = myList->CurrentSelection(); if(i>=0) { BString tmpMessage(""); tmpMessage += myList->Name(); tmpMessage += ":_Invoke:"; // tmpMessage += ((BStringItem*)(myList->ItemAt(i)))->Text(); tmpMessage << i+1; tmpMessage += "|"; messageString += tmpMessage; } } break; case YABLISTBOXSELECT: { BListView *myList; message->FindPointer("source",(void **) &myList); int i = myList->CurrentSelection(); if(i>=0) { BString tmpMessage(""); tmpMessage += myList->Name(); tmpMessage += ":_Select:"; // tmpMessage += ((BStringItem*)(myList->ItemAt(i)))->Text(); tmpMessage << i+1; tmpMessage += "|"; messageString += tmpMessage; } } break; case YABDROPBOX: { BString tmpMessage(""); BMenuItem *myMenuItem; message->FindPointer("source",(void **) &myMenuItem); tmpMessage += (myMenuItem->Menu())->Supermenu()->Parent()->Name(); tmpMessage += ":"; tmpMessage += myMenuItem->Label(); tmpMessage += "|"; messageString += tmpMessage; } break; case YABSLIDER: { BString tmpMessage(""); BSlider *mySlider; message->FindPointer("source",(void **) &mySlider); tmpMessage += mySlider->Name(); tmpMessage += ":"; tmpMessage << mySlider->Value(); tmpMessage += "|"; messageString += tmpMessage; } break; case YABCOLORCONTROL: { rgb_color col; BString tmpMessage(""); BColorControl *myCControl; message->FindPointer("source",(void **) &myCControl); tmpMessage += myCControl->Name(); tmpMessage += ":"; col = myCControl->ValueAsColor(); tmpMessage << col.red << ":" << col.green << ":" << col.blue; tmpMessage += "|"; messageString += tmpMessage; } break; case YABTREEBOXINVOKE: { BOutlineListView *myList; message->FindPointer("source",(void **) &myList); int i = myList->FullListCurrentSelection(); if(i>=0) { BString tmpMessage(""); const char* txt = ((BStringItem*)(myList->FullListItemAt(i)))->Text(); tmpMessage += myList->Name(); tmpMessage += ":_Invoke:"; tmpMessage << i+1; /* int n = tmpMessage.Length(); BListItem *superitem = myList->Superitem(myList->FullListItemAt(i)); while(superitem) { BString t(""); t << ((BStringItem*)superitem)->Text() << ":"; tmpMessage.Insert(t,n); superitem = myList->Superitem(superitem); } tmpMessage += txt;*/ tmpMessage += "|"; messageString += tmpMessage; } } break; case YABTREEBOXSELECT: { BOutlineListView *myList; message->FindPointer("source",(void **) &myList); int i = myList->FullListCurrentSelection(); if(i>=0) { BString tmpMessage(""); const char* txt = ((BStringItem*)(myList->FullListItemAt(i)))->Text(); tmpMessage += myList->Name(); tmpMessage += ":_Select:"; tmpMessage << i+1; /* int n = tmpMessage.Length(); BListItem *superitem = myList->Superitem(myList->FullListItemAt(i)); while(superitem) { BString t(""); t << ((BStringItem*)superitem)->Text() << ":"; tmpMessage.Insert(t,n); superitem = myList->Superitem(superitem); } tmpMessage += txt;*/ tmpMessage += "|"; messageString += tmpMessage; } } break; case YABFILEBOXSELECT: { BColumnListView *myList; message->FindPointer("source",(void **) &myList); BRow *myRow = NULL; if(myList) myRow = myList->CurrentSelection(); if(myRow) { // if(!myList->IsFocus()) myList->MakeFocus(); BString tmpMessage(""); tmpMessage += myList->Name(); tmpMessage += ":_Select:"; tmpMessage << myList->IndexOf(myRow)+1; tmpMessage += "|"; messageString += tmpMessage; } } break; case YABFILEBOXINVOKE: { BColumnListView *myList; message->FindPointer("source",(void **) &myList); BRow *myRow = NULL; if(myList) myRow = myList->CurrentSelection(); if(myRow) { // if(!myList->IsFocus()) myList->MakeFocus(); BString tmpMessage(""); tmpMessage += myList->Name(); tmpMessage += ":_Invoke:"; tmpMessage << myList->IndexOf(myRow)+1; tmpMessage += "|"; messageString += tmpMessage; } } break; case YABSHORTCUT: { const char* myMsg; if(message->FindString("shortcut", &myMsg) == B_OK) { messageString += myMsg; messageString += "|"; } } break; default: BWindow::MessageReceived(message); break; } }
/** * @brief Returns an index of selected item. * @return item index of selected item. or -1 if no item is selected. */ SInt32 BeColumnListViewAdapter::GetSelectedItem() { BColumnListView* listView = getColumnListView(); BRow* row = listView->CurrentSelection(); return listView->IndexOf(row); }