status_t
EnumerationValueHandler::CreateTableCellValueRenderer(IntegerValue* _value,
	IntegerValueFormatter::Config* config,
	TableCellValueRenderer*& _renderer)
{
	EnumerationValue* value = dynamic_cast<EnumerationValue*>(_value);
	if (value != NULL
		&& value->GetType()->ValueFor(value->GetValue()) != NULL) {
		ValueFormatter* formatter = NULL;
		status_t error = GetValueFormatter(value, formatter);
		if (error != B_OK)
			return error;
		BReference<ValueFormatter> formatterReference(formatter,
			true);

		TableCellValueRenderer* renderer
			= new(std::nothrow) TableCellFormattedValueRenderer(formatter);
		if (renderer == NULL)
			return B_NO_MEMORY;

		_renderer = renderer;
		return B_OK;
	}

	return IntegerValueHandler::CreateTableCellValueRenderer(_value, config,
		_renderer);
}
Пример #2
0
status_t
EnumerationValueHandler::GetTableCellValueEditor(Value* _value,
	Settings* settings, TableCellValueEditor*& _editor)
{
	EnumerationValue* value = dynamic_cast<EnumerationValue*>(_value);
	if (value == NULL)
		return B_BAD_VALUE;

	IntegerValueFormatter::Config* config = NULL;
	status_t error = CreateIntegerFormatterConfig(value, config);
	if (error != B_OK)
		return error;
	BReference<IntegerValueFormatter::Config> configReference(config, true);

	ValueFormatter* formatter;
	error = CreateValueFormatter(config, formatter);
	if (error != B_OK)
		return error;
	BReference<ValueFormatter> formatterReference(formatter, true);

	TableCellEnumerationEditor* editor = new(std::nothrow)
		TableCellEnumerationEditor(value, formatter);
	if (editor == NULL)
		return B_NO_MEMORY;

	BReference<TableCellEnumerationEditor> editorReference(editor, true);
	error = editor->Init();
	if (error != B_OK)
		return error;

	editorReference.Detach();
	_editor = editor;
	return B_OK;
}
Пример #3
0
status_t
BoolValueHandler::GetTableCellValueRenderer(Value* value,
	TableCellValueRenderer*& _renderer)
{
	if (dynamic_cast<BoolValue*>(value) == NULL)
		return B_BAD_VALUE;

	ValueFormatter* formatter = NULL;
	if (GetValueFormatter(value, formatter))
		return B_NO_MEMORY;
	BReference<ValueFormatter> formatterReference(formatter, true);

	// create the renderer
	TableCellValueRenderer* renderer
		= new(std::nothrow) TableCellFormattedValueRenderer(formatter);
	if (renderer == NULL)
		return B_NO_MEMORY;

	_renderer = renderer;
	return B_OK;
}