How to identify a ListCtrlItem when it is just saved as a Pointer within a GroupComboBox?

Hi there,

I am writing a c++ - Rhino 6 plugin in which an existing software should expose some of its functionality to Rhino.
I am currently working on the GUI and wrote some functionality to automatically generate a Rhino GUI from a system of options in my original software. Now, in order to update the Rhino-Gui when a change in one option ripples to other options, i want to clearly identify these options by checking their parent (this is due to me identifying them by their label, which is not per se unique…)

Is that possible and/or are there better alternatives?

What conditions does the function CRhinoUiOptionsListCtrlItem::SetParentIndex(int idx) have? So far it always returns false and does not update the item’s parentIndex when i invoke it. Unfortunately it doesn’t have a comment in the API-doc either :wink:

I’m just starting with Rhino-development, so any hint is well taken.
Thank you for your time,

Oliver

Can you send me a simple sample so I can see what you are trying to do?

Sure, lets say i have a bunch of somethings called “Positioning Strategy”, and each of them contain a bunch of options users should be able to set; I want those options to be displayed in my Rhino Plugin, but only those belonging to the selected Positioning Strategy. Therefore I created a Combobox

CRhinoUiOptionsListCtrlGroupComboBox m_PositioningStrategy;

and at some point during startup I use my existing options to fill it:

foreach(auto posStrategy, setup->getPositioningStrategies()) {
	auto name(posStrategy->getName());
	WinFormFromOptionController::addToRhinoGroupCombobox(name,
			posStrategy->getOptions(*setup),
			m_PositioningStrategy,
			m_PositioningStrategy.IndentLevel()
	);
	
	positioningStrategyIndizes.insert(std::pair<ipt::String, int>(name, i));
}

In WinFormFromOptionController::addToRhinoGroupCombobox I now add my options to that GroupComboBox

bool ipt::WinFormFromOptionController::addToRhinoGroupCombobox(
const String& name,
SharedPointer<OptionController> oc,
CRhinoUiOptionsListCtrlGroupComboBox& combo,
int indentLevel)
{
	if (!oc) {
		return false;
	}
	
	bool translatedAllOptions = true;
	ON_SimpleArray<CRhinoUiOptionsListCtrlItem*> items;

	// OptionController contains our internal option structure
	foreach(auto sibling, oc->getOptionSiblings()) {
		CRhinoUiOptionsListCtrlSeparator* sib(new CRhinoUiOptionsListCtrlSeparator(sibling->getId().toStdWString().c_str(), indentLevel + 1));
		items.Append(sib);

		foreach(auto group, sibling->getOptionGroups()) {
			CRhinoUiOptionsListCtrlSeparator* gr(new CRhinoUiOptionsListCtrlSeparator(group->getId().toStdWString().c_str(), indentLevel+2));
			items.Append(gr);

			foreach(auto option, group->getOptions()) {
				{
					auto bo(option.dynamicCast<BooleanOption>());
					if (bo) {
						CRhinoUiOptionsListCtrlCheckBox* checkBox(new CRhinoUiOptionsListCtrlCheckBox(bo->getId().toStdWString().c_str(), L"Activated", indentLevel + 2));
						checkBox->SetCheck(bo->getValue());
						checkBox->SetIndentLevel(indentLevel + 2);
						setItemStates(checkBox, option);
						items.Append(checkBox);
						continue;
					}
				} 
				{
					auto dblo(option.dynamicCast<DoubleOption>());
					if (dblo) {
						CRhinoUiOptionsListCtrlEditBox* dblEdit(new CRhinoUiOptionsListCtrlEditBox(dblo->getId().toStdWString().c_str()));

						dblEdit->SetEditType(CRhinoUiEdit::edit_type::et_double);
						dblEdit->SetText(Double(dblo->getValue()).toString().toStdWString().c_str());
						dblEdit->SetIndentLevel(indentLevel + 2);
						setItemStates(dblEdit, option);
						items.Append(dblEdit);
						continue;
					}
				}
				{
					//.... cast and append all the other option types
				}
				
				// catch having forgotten an option type...
				translatedAllOptions = false;
			}
		}
	}
	
	combo.AddGroupItem(name.toStdWString().c_str(), items);
	return translatedAllOptions;

}

Later I want to identify these options in Callbacks such as

 void CRhinoUiOptionsListCtrl::OnItemComboBoxSelChanged(CRhinoUiOptionsListCtrlComboBox& item)

or

bool CCalmOptionsControl::OnItemButtonClicked(CRhinoUiOptionsListCtrlCheckBox& item)

Simply put: Is there an elegant way to find out, to which CRhinoUiOptionsListCtrlComboBox an item like CRhinoUiOptionsListCtrlCheckBox belongs? The label is not sufficient because I cannot guarantee uniqueness.