1/*
2 * Copyright 2009, Ingo Weinhold, ingo_weinhold@gmx.de.
3 * Distributed under the terms of the MIT License.
4 */
5
6
7#include "BoolValueHandler.h"
8
9#include <new>
10
11#include "BoolValue.h"
12#include "TableCellBoolRenderer.h"
13
14
15BoolValueHandler::BoolValueHandler()
16{
17}
18
19
20BoolValueHandler::~BoolValueHandler()
21{
22}
23
24
25status_t
26BoolValueHandler::Init()
27{
28	return B_OK;
29}
30
31
32float
33BoolValueHandler::SupportsValue(Value* value)
34{
35	return dynamic_cast<BoolValue*>(value) != NULL ? 0.5f : 0;
36}
37
38
39status_t
40BoolValueHandler::GetValueFormatter(Value* value,
41	ValueFormatter*& _formatter)
42{
43	// TODO:...
44	return B_UNSUPPORTED;
45}
46
47
48status_t
49BoolValueHandler::GetTableCellValueRenderer(Value* value,
50	TableCellValueRenderer*& _renderer)
51{
52	if (dynamic_cast<BoolValue*>(value) == NULL)
53		return B_BAD_VALUE;
54
55	// create the renderer
56	TableCellValueRenderer* renderer = new(std::nothrow) TableCellBoolRenderer;
57	if (renderer == NULL)
58		return B_NO_MEMORY;
59
60	_renderer = renderer;
61	return B_OK;
62}
63