Esempio n. 1
0
/*	FillMenuNoMeta(theMenu, itemList, itemListLen, afterItem)

	This routine works exactly like FillMenu except that it does not honor
	meta-characters. For example, the Macintosh Menu Manager treats left
	parenthesis as a meta-character. If you add an item to a menu that contains a
	left parenthesis, the item is added as a disabled item and the left parenthesis
	is omitted. This behavior sometimes is not what the programmer intended. Using
	FillMenuNoMeta instead of FillMenu causes the Macintosh menu manager to skip
	the special treatment of such characters. 

	itemList is a semicolon separated list of items to be put into theMenu.
	itemListLen is the total number of characters in itemList.
	afterItem specifies where the items in itemList are to appear in the menu.
		afterItem = 0			new items appear at beginning of menu
		afterItem = 10000		new items appear at end of menu
		afterItem = item number	new items appear after specified existing item number.
	
	NOTE: Do not call this routine to update the contents of an existing
		  dialog popup menu item. Use FillPopMenu instead.
	
	Thread Safety: FillMenuNoMeta is not thread-safe.
*/
void
FillMenuNoMeta(MenuHandle theMenu, const char *itemList, int itemListLen, int afterItem)
{
	const char *p1;
	const char *p2;
	char itemText[256];
	int len, itemLen;
	int newItemNumber;
	
	if (!CheckRunningInMainThread("FillMenuNoMeta"))
		return;
	
	newItemNumber = afterItem + 1;
	if (newItemNumber > 10000)
		newItemNumber = CountMItems(theMenu) + 1;

	p1 = itemList;
	while (itemListLen > 0) {
		if (p2 = strchr(p1, ';'))
			len = (int)(p2 - p1);
		else
			len = itemListLen;								// Last one.
		itemLen = len;
		if (itemLen > 255)
			itemLen = 255;
		strncpy(itemText, p1, itemLen);
		itemText[itemLen] = 0;
		insertmenuitem(theMenu, "x", afterItem);
		setmenuitemtext(theMenu, newItemNumber, itemText);	// This call does not treat certain characters as meta-characters.
		p1 += len+1;
		itemListLen -= len+1;
		afterItem += 1;
		newItemNumber += 1;
	}
}
Esempio n. 2
0
/*	WMDeleteMenuItems(theMenu, afterItem)

	Deletes the contents of the existing dialog popup menu after the
	specified item.
	
	afterItem is 1-based. If afterItem is zero, all items are deleted.
	
	NOTE: You should not call this routine to delete the contents of an existing
		  dialog popup menu item. Use DeletePopMenuItems instead.
	
	HR, 010427: This was previously called WMDeleteMenuItems but Apple usurped that name.
	
	Thread Safety: WMDeleteMenuItems is not thread-safe.
*/
void
WMDeleteMenuItems(MenuHandle theMenu, int afterItem)
{
	int item, items;
	
	if (!CheckRunningInMainThread("WMDeleteMenuItems"))
		return;
	
	afterItem++;						/* # of first item to delete */
	items = CountMItems(theMenu);
	
	for (item = afterItem; item <= items; item++)
		DeleteMenuItem(theMenu, afterItem);
}
Esempio n. 3
0
void XGPopControl::ReloadItems (void)
{
	MenuHandle menu;
	int ix, len;
	char buf[256];

	if (!fControl)
		return;

	XGDraw draw(this,false);

	menu = GetMenuHandle();
	if (!menu)
		return;

#if TARGET_CARBON
	for (ix = CountMenuItems(menu); ix > 0; ix--) DeleteMenuItem(menu, ix);
#else
	for (ix = CountMItems(menu); ix > 0; ix--) DeleteMenuItem(menu, ix);
#endif

	for (ix = 0; ix < fList.GetNumStrings(); ix++) {
		fList.GetString(ix, buf);
		len = strlen(buf);
		memmove(&buf[1], buf, len);
		buf[0] = len;
		AppendMenu(menu, "\px");
		SetMenuItemText(menu, ix + 1, (unsigned char *)buf);
	}

#if TARGET_CARBON
	SetControlMaximum(fControl, CountMenuItems(menu));
#else
	SetControlMaximum(fControl, CountMItems(menu));
#endif
	SetControlValue(fControl, fValue + 1);
}
Esempio n. 4
0
/*	GetMenuHandleAndItem(menuIDIn, itemNumberIn, mHandleOut, itemNumberOut)

	menuIDIn and itemNumberIn are parameters supplied to MenuXOP1 enable or MenuXOP1 disable.
	
	Returns menu handle and item number via mHandleOut, itemNumberOut.
	*mHandleOut will be NULL if the specified menu is hidden.
	
	Function result is 0 if OK or error code.
*/
static int
GetMenuHandleAndItem(int menuIDIn, int itemNumberIn, MenuHandle* mHandleOut, int* itemNumberOut)
{
	MenuHandle mHandle;
	int menuID, itemNumber;
	int isIgorMenu;

	*mHandleOut = NULL;
	*itemNumberOut = 0;
	
	menuID = ResourceToActualMenuID(menuIDIn);
	isIgorMenu = menuID == 0;
	if (isIgorMenu) {
		menuID = menuIDIn;				// Presumably an Igor menu with item added by XOP.
		if (menuID!=MISCID && menuID!=ANALYSISID)
			return BAD_MENU_ID;			// Only these menus are supported by MenuXOP1.
	}

	itemNumber = itemNumberIn;
	if (isIgorMenu) {
		if (ActualToResourceItem(menuID,itemNumber) == 0)
			return BAD_ITEM_NUM;
	}

	mHandle = GetMenuHandle(menuID);
	if (mHandle == NULL)
		return 0;						// Menu is hidden -- not in menu bar.
		
	if (itemNumber<1 || itemNumber>CountMItems(mHandle))
		return BAD_ITEM_NUM;
		
	*mHandleOut = mHandle;
	*itemNumberOut = itemNumber;
	
	return 0;
}
Esempio n. 5
0
void 	RchooseDialog::setDialogState(void)
{
int i,m;
MenuHandle menuH;
short menucount;
	short		item;	
	short		iType;
	Handle		iHandle;
	Rect 		iRect;	
	
	
switch (_which) {
	case DT_TiffFile:
		if (DataFile < 0) _which = 1;
		break;
	case DT_DTP51:
		if (DTP51 < 0) _which = 1;
		break;
	case DT_XriteDTP41:
		if (DTP41 < 0) _which = 1;
		break;
	case DT_TechkonCP300:
		if (TechkonCP300 < 0) _which = 1;
		break;
	case DT_TechkonSP820:
		if (TechkonSP820 < 0) _which = 1;
		break;
	case DT_TechkonTCRCP300:
		if (TechkonTCRCP300 < 0) _which = 1;
		break;
	case DT_TechkonTCRSP820:
		if (TechkonTCRSP820 < 0) _which = 1;
		break;
	case DT_GretagHand:
		if (GretagHand < 0) _which = 1;
		break;
	case DT_GretagTable:
		if (GretagTable < 0) _which = 1;
		break;
	case DT_Xrite408:
		if (XR408 < 0) _which = 1;
		break;
	}	
	

switch (_which) {
	case (DT_DataFile):
		Disable(dialogptr,PatchFormat);
		Disable(dialogptr,DevicePort);
		menuH = GetMenu(Table_menu);
		menucount = CountMItems(menuH);

		for( i = menucount; i > 0; i-- )
			DelMenuItem(menuH,i);
			
		_which_patch = 1;
		GetDItem (dialogptr, PatchFormat, &iType, &iHandle, &iRect);
		SetCtlValue((ControlHandle)iHandle,_which_patch);
		DrawControls(dialogptr);
		break;
	case (DT_DTP51):
		Enable(dialogptr,PatchFormat);
		Enable(dialogptr,DevicePort);
		menuH = GetMenu(Table_menu);
		menucount = CountMItems(menuH);

		for( i = menucount; i > 0; i-- )
			DelMenuItem(menuH,i);
		
		m = 1;
		for (i=0; i<doc->patchset->filenum; i++)
			{
			if (doc->patchset->patches[i] != NULL)
				{
				if ( doc->patchset->patches[i]->patches.strips == 1) 
					{
					convert[m] = i;
					convert2[i] = m;
					InsMenuItem(menuH, doc->patchset->patchames[i], m++);
					}
				}
			}
			
		//_which_patch = 1;
		GetDItem (dialogptr, PatchFormat, &iType, &iHandle, &iRect);
		SetCtlValue((ControlHandle)iHandle,convert2[_which_patch]);
		GetDItem (dialogptr, DevicePort, &iType, &iHandle, &iRect);
		SetCtlValue((ControlHandle)iHandle,_which_port);
		DrawControls(dialogptr);
		break;
	case (DT_TiffFile):
		Enable(dialogptr,PatchFormat);
		Disable(dialogptr,DevicePort);
		
		menuH = GetMenu(Table_menu);
		menucount = CountMItems(menuH);

		for( i = menucount; i > 0; i-- )
			DelMenuItem(menuH,i);
		
		m = 1;
		for (i=0; i<doc->patchset->filenum; i++)
			{
			if (doc->patchset->patches[i] != NULL)
				{
				if (doc->patchset->patches[i]->patches.strips == 0) 
					{
					convert[m] = i;
					convert2[i] = m;
					InsMenuItem(menuH, doc->patchset->patchames[i], m++);
					}
				}
			}
		//_which_patch = 1;
		GetDItem (dialogptr, PatchFormat, &iType, &iHandle, &iRect);
		SetCtlValue((ControlHandle)iHandle,convert2[_which_patch]);
		GetDItem (dialogptr, DevicePort, &iType, &iHandle, &iRect);
		SetCtlValue((ControlHandle)iHandle,_which_port);
		DrawControls(dialogptr);
		break;
	case (DT_TechkonCP300):
	case (DT_TechkonSP820):
	case (DT_TechkonTCRCP300):
	case (DT_TechkonTCRSP820):
	case (DT_GretagHand):
	case (DT_GretagTable):
		Enable(dialogptr,PatchFormat);
		Enable(dialogptr,DevicePort);
		
		menuH = GetMenu(Table_menu);
		menucount = CountMItems(menuH);

		for( i = menucount; i > 0; i-- )
			DelMenuItem(menuH,i);
		
		m = 1;
		for (i=0; i<doc->patchset->filenum; i++)
			{
			if (doc->patchset->patches[i] != NULL)
				{
				if (doc->patchset->patches[i]->patches.strips == 0) 
					{
					convert[m] = i;
					convert2[i] = m;
					InsMenuItem(menuH, doc->patchset->patchames[i], m++);
					}
				}
			}
		//_which_patch = 1;
		GetDItem (dialogptr, PatchFormat, &iType, &iHandle, &iRect);
		SetCtlValue((ControlHandle)iHandle,convert2[_which_patch]);
		GetDItem (dialogptr, DevicePort, &iType, &iHandle, &iRect);
		SetCtlValue((ControlHandle)iHandle,_which_port);
		DrawControls(dialogptr);
		break;
	case (DT_Xrite408):
		Disable(dialogptr,PatchFormat);
		break;
	}
	
if ((!density) && (_which == DT_Xrite408)) Disable(dialogptr,1);
else Enable(dialogptr,1);	

}