Exemple #1
0
//------------------------------------------------------------------------
COptionMenu* UIDescriptionTestController::createContextMenu (const CPoint& pos, VST3Editor* editor)
{
	Parameter* tabParameter = getParameterObject (20000);
	if (tabParameter)
	{
		UIDescriptionTestControllerMenuHandler* menuHandler = new UIDescriptionTestControllerMenuHandler (tabParameter);
		COptionMenu* menu = new COptionMenu ();
		menu->setStyle (kMultipleCheckStyle);
		for (int32 i = 0; i <= tabParameter->getInfo ().stepCount; i++)
		{
			String128 valueString;
			tabParameter->toString (tabParameter->toNormalized (i), valueString);
			String str (valueString);
			str.toMultiByte (kCP_Utf8);
			CMenuItem* item = menu->addEntry (new CCommandMenuItem (str.text8 (), i, menuHandler));
			if (tabParameter->getNormalized () == tabParameter->toNormalized (i))
				item->setChecked (true);
		}
		COptionMenu* mainMenu = new COptionMenu ();
		mainMenu->addEntry (new CMenuItem ("Show Tab"))->setSubmenu (menu);
		menuHandler->forget ();
		return mainMenu;
	}
	return 0;
}
//----------------------------------------------------------------------------------------------------
CMouseEventResult UIViewCreatorDataSource::dbOnMouseDown (const CPoint& where, const CButtonState& buttons, int32_t row, int32_t column, CDataBrowser* browser)
{
	mouseDownRow = row;
	if (buttons.isLeftButton ())
	{
		if (!buttons.isDoubleClick ())
			return kMouseEventHandled;
		addViewToCurrentEditView ();
	}
	else if (buttons.isRightButton ())
	{
		const std::string& viewName = getStringList ()->at (static_cast<uint32_t> (mouseDownRow));
		std::string menuEntryName = "Add a new '" + viewName + "'";
		COptionMenu menu;
		menu.setStyle (kPopupStyle);
		menu.addEntry (menuEntryName.c_str ());
		CPoint menuLocation (where);
		browser->localToFrame (menuLocation);
		if (menu.popup (browser->getFrame (), menuLocation))
		{
			if (menu.getEntry (menu.getLastResult ()))
				addViewToCurrentEditView ();
		}
	}
	mouseDownRow = -1;
	return kMouseDownEventHandledButDontNeedMovedOrUpEvents;
}