void PreferencesDialog::initDialog() { ControlHandle popupButtonControl; ControlID popupButtonControlID = {kAppSignature, 130}; MenuRef menu; GetControlByID(preferencesWindow, &popupButtonControlID, &popupButtonControl); GetControlData(popupButtonControl, kControlEntireControl, kControlPopupButtonMenuRefTag, sizeof(menu), &menu, NULL); unsigned int nPorts = midiin ? midiin->getPortCount() : 0; if (nPorts) { UInt32 numItems = CountMenuItems(menu); DeleteMenuItems(menu, 1, numItems); // Check inputs. std::string portName; unsigned int nSelectedDevice = 0; for (unsigned int i = 0; i < nPorts; i++ ) { try { portName = midiin->getPortName(i); } catch (RtMidiError &error) { error.printMessage(); } if (strcmp(portName.c_str(), m_dataBase->restore(KEY_MIDIDEVICE)->getStringValue()) == 0) nSelectedDevice = i; CFStringRef CFStrPortName = CFStringCreateWithCString(NULL, portName.c_str(), kCFStringEncodingASCII); AppendMenuItemTextWithCFString(menu, CFStrPortName, 0, kMIDIDeviceBaseCommand + i, 0); CFRelease(CFStrPortName); } /*AppendMenuItemTextWithCFString(menu, CFSTR("Temp1"), 0, kMIDIDeviceBaseCommand + 1, 0); AppendMenuItemTextWithCFString(menu, CFSTR("Temp2"), 0, kMIDIDeviceBaseCommand + 2, 0); nPorts+=2;*/ SetControlMaximum(popupButtonControl, nPorts); SetControlValue(popupButtonControl, nSelectedDevice + 1); storeMidiDeviceName(nSelectedDevice); EnableControl(popupButtonControl); } else { DisableControl(popupButtonControl); } updateControls(); updateSliderVelocityAmplify(); }
//================================================ void SpecialFolder::UpdateFolder(void) { // --------------------------------------- // remember the active item as text MenuItem *ActiveItem = m_pActiveItem; TCHAR *active_item_text = NULL; m_pLastChild = m_pChild; if (m_pLastChild) ActiveItem = m_pLastChild->m_pParentItem; if (ActiveItem) active_item_text = new_str(ActiveItem->m_pszTitle); // delete_old items DeleteMenuItems(); // load the folder contents MenuItem *Items = NULL; int r = 0; struct pidl_node *p; dolist (p, m_pidl_list) r |= MenuMaker_LoadFolder(&Items, p->v, m_pszExtra); if (Items) add_folder_contents(Items, NULL != m_pidl_list->next); else if (r) MakeMenuNOP(this, NLS0(_T("No Files"))); else MakeMenuNOP(this, NLS0(_T("Invalid Path"))); // --------------------------------------- // search by text the previously active item if (active_item_text) { dolist (ActiveItem, m_pMenuItems) if (0 == _tcscmp(active_item_text, ActiveItem->m_pszTitle)) break; free_str(&active_item_text); } // --------------------------------------- // possibly reconnect to an open child-folder if (m_pLastChild) { if (ActiveItem) { m_pLastChild->incref(); ActiveItem->LinkSubmenu(m_pLastChild); m_pLastChild->LinkToParentItem(ActiveItem); } else { m_pLastChild->Hide(); // lost child } m_pLastChild = NULL; } if (ActiveItem) ActiveItem->Active(2); }
void OPL_LoginDialog::fill_dir_menu(char *path) { char *tmp_dir, *prov, *dir; MenuRef items_m; int i = -1; ControlRef f_select; getControl(kLoginDIR, &f_select); if (!path || !(prov = strdup (path))) return; if (prov[strlen(prov) - 1] == '/' && strlen(prov) > 1) prov[strlen(prov) - 1] = 0; items_m = GetControlPopupMenuHandle (f_select); DeleteMenuItems (items_m, 1, CountMenuItems (items_m)); /* Add the root directory */ AppendMenuItemTextWithCFString(items_m, CFSTR("/"), 0, 0, NULL); for (tmp_dir = prov, dir = NULL; tmp_dir; tmp_dir = strchr (tmp_dir + 1, '/')) { if (strchr (tmp_dir + 1, '/')) { dir = strchr (tmp_dir + 1, '/'); *dir = 0; } AppendMenuItemTextWithCFString(items_m, OPL_char_to_CFString(prov), 0, 0, NULL); if (dir) *dir = '/'; } i = CountMenuItems (items_m); SetControlMaximum (f_select, i); SetControlValue (f_select, i); if (cur_dir) free(cur_dir); cur_dir = prov; }
static void fill_dir_menu(TDSNCHOOSER *dsnchoose_t, char *path) { char *curr_dir, *prov, *dir; MenuRef items_m; int i = -1; CFStringRef str; ControlRef f_select = dsnchoose_t->fdir; if (!path || !(prov = strdup (path))) return; if (prov[strlen(prov) - 1] == '/' && strlen(prov) > 1) prov[strlen(prov) - 1] = 0; items_m = GetControlPopupMenuHandle (f_select); DeleteMenuItems (items_m, 1, CountMenuItems (items_m)); /* Add the root directory */ AppendMenuItemTextWithCFString(items_m, CFSTR("/"), 0, 0, NULL); if (strlen(prov) > 1) for (curr_dir = prov, dir = NULL; curr_dir; curr_dir = strchr (curr_dir + 1, '/')) { if (strchr (curr_dir + 1, '/')) { dir = strchr (curr_dir + 1, '/'); *dir = 0; } str = CFStringCreateWithCString(NULL, prov, kCFStringEncodingUTF8); AppendMenuItemTextWithCFString(items_m, str, 0, 0, NULL); if (dir) *dir = '/'; } i = CountMenuItems (items_m); SetControlMaximum (f_select, i); SetControlValue (f_select, i); strncpy(dsnchoose_t->curr_dir, prov, sizeof(dsnchoose_t->curr_dir)); }