2 * Copyright 2009, Ingo Weinhold, ingo_weinhold@gmx.de.
3 * Distributed under the terms of the MIT License.
7 #include "FloatValueHandler.h"
11 #include "FloatValue.h"
12 #include "FloatValueFormatter.h"
13 #include "TableCellFloatEditor.h"
14 #include "TableCellFormattedValueRenderer.h"
17 FloatValueHandler::FloatValueHandler()
22 FloatValueHandler::~FloatValueHandler()
28 FloatValueHandler::Init()
35 FloatValueHandler::SupportsValue(Value
* value
)
37 return dynamic_cast<FloatValue
*>(value
) != NULL
? 0.5f
: 0;
42 FloatValueHandler::GetValueFormatter(Value
* value
,
43 ValueFormatter
*& _formatter
)
45 if (dynamic_cast<FloatValue
*>(value
) == NULL
)
48 FloatValueFormatter
* formatter
= new(std::nothrow
) FloatValueFormatter
;
49 if (formatter
== NULL
)
52 _formatter
= formatter
;
58 FloatValueHandler::GetTableCellValueRenderer(Value
* value
,
59 TableCellValueRenderer
*& _renderer
)
61 if (dynamic_cast<FloatValue
*>(value
) == NULL
)
64 ValueFormatter
* formatter
= NULL
;
65 status_t error
= GetValueFormatter(value
, formatter
);
68 BReference
<ValueFormatter
> formatterReference(formatter
, true);
70 // create the renderer
71 TableCellValueRenderer
* renderer
72 = new(std::nothrow
) TableCellFormattedValueRenderer(formatter
);
82 FloatValueHandler::GetTableCellValueEditor(Value
* _value
, Settings
* settings
,
83 TableCellValueEditor
*& _editor
)
85 FloatValue
* value
= dynamic_cast<FloatValue
*>(_value
);
89 ValueFormatter
* formatter
;
90 status_t error
= GetValueFormatter(value
, formatter
);
93 BReference
<ValueFormatter
> formatterReference(formatter
, true);
95 TableCellFloatEditor
* editor
= new(std::nothrow
)
96 TableCellFloatEditor(value
, formatter
);
100 BReference
<TableCellFloatEditor
> editorReference(editor
, true);
101 error
= editor
->Init();
105 editorReference
.Detach();