2 * Copyright 2015, Rene Gollent, rene@gollent.com.
3 * Distributed under the terms of the MIT License.
6 #include "TableCellEnumerationEditor.h"
8 #include "EnumerationValue.h"
12 TableCellEnumerationEditor::TableCellEnumerationEditor(::Value
* initialValue
,
13 ValueFormatter
* formatter
)
15 TableCellOptionPopUpEditor(initialValue
, formatter
)
20 TableCellEnumerationEditor::~TableCellEnumerationEditor()
26 TableCellEnumerationEditor::ConfigureOptions()
28 EnumerationValue
* initialValue
= dynamic_cast<EnumerationValue
*>(
30 if (initialValue
== NULL
)
33 EnumerationType
* type
= initialValue
->GetType();
34 for (int32 i
= 0; i
< type
->CountValues(); i
++) {
35 EnumeratorValue
* value
= type
->ValueAt(i
);
38 status_t error
= AddOption(value
->Name(), value
->Value().ToInt32());
43 BVariant integerValue
;
44 if (!initialValue
->ToVariant(integerValue
))
47 SelectOptionFor(integerValue
.ToInt32());
54 TableCellEnumerationEditor::GetSelectedValue(::Value
*& _value
) const
56 EnumerationValue
* initialValue
= dynamic_cast<EnumerationValue
*>(
58 EnumerationType
* type
= initialValue
->GetType();
59 const char* name
= NULL
;
60 int32 selectedValue
= 0;
61 SelectedOption(&name
, &selectedValue
);
63 EnumerationValue
* value
= new(std::nothrow
) EnumerationValue(type
,
64 BVariant(selectedValue
));